I have added Required attribute to one of my properties of Model class as follows -
[Required(ErrorMessage="UserID should not be blank")]
[DisplayName("User Name")]
public string UserName { get; set; }
Inside my view, which inherits the class containing above property, I have tried to apply validaton to a textbox as follows -
<%= Html.TextBoxFor(model => Model.UserName, new { @class = "login-input", @name="UserName" })%>
<%= Html.ValidationMessageFor(model => Model.UserName)%>
But when I run this app, and invokes the post(using a button click), without entering anything in the textbox; I don't get the text box validated?
Can anyone please tell me what may be the reason that is prohibiting the textbox validation?
Thanks in advance, kaps