asp.net mvc - Textbox validation in MVC2 -
I've added the required attribute for one of the properties of the model class -
< Code> [required (error message = "user id should not be blank")] [DisplayName ("username")] public string username {get; Set; }
Inside my view, which inherits the class of properties above, I have tried to apply validation in a text box as follows -
& lt;% = Html.TextBoxFor (model = & gt; Model.UserName, new {@class = "login-input", @ name = "UserName"})%> & Lt;% = HTML.ValidationMessageFor (Model = & gt; Model.UserName)% & gt;
But when I run this app, clicking on a button without clicking on the button; Do not I get the text box valid?
Can anyone tell me what is the reason that the text box verification can be stopped?
/ Strong>. Model => User Name> for model User Name
Comments
Post a Comment