I have this code in my view page.
<td>
Mandate Name:
</td>
<td>
<%= Html.TextBox("MandateName")%>
</td>
I wrote MVC2 Validation for this name.
something like this.
//[Validator(typeof(MandateValidator))]
[MetadataType(typeof(Mandate_Metadata))]
public partial class Mandate {
public class Mandate_Metadata
{
[StringLength(250, ErrorMessage = "Mandate name cannot exceed 250 characters!")]
[Required(ErrorMessage = "Mandate Name Required!")]
public string MandateName { get; set; }
[StringLength(3000, ErrorMessage = "Description cannot exceed 3000 characters!")]
public string MandateDescription { get; set; }
}
}
but some how my validation is not working on this field could any body help me what’s wrong I am doing here?
thanks
do you have anything like
in your view?
Check out SottGu’s post on Model Validation with mvc2.