for starters , why would you want to assign a value to password textboxes?
because a user must type in the password even on Edit mode ...
for example ask just ask them for current and new + confirm password
MVC 3
using System.ComponentModel.DataAnnotations;
public class EditUserModel
{
[Required]
[DataType(DataType.Password)]
[Display(Name = "Current password")]
public string OldPassword { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm new password")]
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
Marked as answer by Ming Xu - MSFT on Apr 09, 2012 02:47 PM
rageshS
Member
664 Points
319 Posts
How to set Password Textbox value
Mar 30, 2012 05:54 AM|LINK
I create a edit user settings page in my web site. but the password and confirm password are always empty.
how to assign password textbox with value.
Ramesh T
Contributor
5121 Points
827 Posts
Re: How to set Password Textbox value
Mar 30, 2012 05:57 AM|LINK
This may help u. Simply add
PasswordTextBox.Attributes.Add("value", "ThePassword");rageshS
Member
664 Points
319 Posts
Re: How to set Password Textbox value
Mar 30, 2012 06:18 AM|LINK
thanks for valuable replay, but i use MVC
<div class="editor-field">
@Html.PasswordFor(model => model.Password)
@Html.ValidationMessageFor(model => model.Password)
</div>
.NetBoy
Member
439 Points
115 Posts
Re: How to set Password Textbox value
Mar 30, 2012 06:28 AM|LINK
for starters , why would you want to assign a value to password textboxes?
because a user must type in the password even on Edit mode ...
for example ask just ask them for current and new + confirm password
MVC 3
using System.ComponentModel.DataAnnotations;
public class EditUserModel
{
[Required]
[DataType(DataType.Password)]
[Display(Name = "Current password")]
public string OldPassword { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm new password")]
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
bweber89
Member
486 Points
119 Posts
Re: How to set Password Textbox value
Mar 30, 2012 06:35 AM|LINK
Hi rageshS
I would try the following code:
@Html.Password("MyPassword", "Pa$$W0rd")The code above is using the HTML helper methods to display a textbox of type "Password" in a cshtml (RazorView) page.
Hope this helps
Junior Software Developer
Young Yang -...
All-Star
21344 Points
1818 Posts
Microsoft
Re: How to set Password Textbox value
Apr 06, 2012 02:42 AM|LINK
Hi
What's you meaning of
Why you want to assign a value to password textbox?
It is in your edit view, so I think you just need to provide a password textbox let user input the password, you dont need to assgin value to it.
Regards
Young Yang
Feedback to us
Develop and promote your apps in Windows Store