My current web project has an administration interface in which user details can be edited (I’m not really revolutionizing, I admit ...). The view uses a strongly typed user model with validation attributes:
public class UserPrototype
{
[Required]
[StringLength(50, MinimumLength = 4)]
public string Username { get; set; }
[Required]
[StringLength(50, MinimumLength = 1)]
public string FirstName { get; set; }
[Required]
[StringLength(50, MinimumLength = 1]
public string LastName { get; set; }
[Required]
[StringLength(250, MinimumLength = 6]
public string Password { get; set; }
}
When the user is updated, I would only like to update those fields in the database that have really changed. The main reason is the password field - the password, of course, is stored as a hash, so when the user returns for editing, there is nothing significant in this field. But validation of model binding requires a valid password.
, , - , ( , javascript)? UserPrototype, Required.