Reputation: 5393
Hi I am trying to create a registration page.I am using linq to sql for creating the data models.And have created an aditional class for accesing the data I do not know if this is the corect way to do it but this is how managed to make it work.
Here is my code:
[Required]
[DataType(DataType.Password)]
[Display(Name="Password")]
public string password
{
get { return member.Password; }
set { member.Password = value; }
}
[Required]
[DataType(DataType.Password)]
[Display(Name = "Confirm Password")]
[Compare("Password" , ErrorMessage = "The password and confirm pasword do not match")]
public string confirmPassword { get;set; }
My database does not have a field for confirm password.I am using the database generated for the Membership API.
When I try to submit the data I get this error:
Could not find a property named Password.
How can I corect this?
Upvotes: 1
Views: 1060
Reputation: 4314
Change your property name to
public string Password
The Compare attributes check the properties name and it is case sensitive, so if the names are not identical be experiencing that exception you were getting.
Upvotes: 1
Reputation: 887453
The error is absolutely correct.
public string password
is lowercase, and .Net is (mostly) case-sensitive.
Upvotes: 3