Reputation: 9081
i have an asp.net mvc4 application in which i have :
<li>
@Html.Label("Login")
@Html.TextBox("Login")
</li>
i'd like to add the attribute Required
to the TextBox login
like this
<input type="Text name="login" Required />
how can i do it?
Upvotes: 0
Views: 59
Reputation: 4835
An alternate way can be to add data annotation in model:
[Required(ErrorMessage = "Field cannot be blank")]
Upvotes: 2
Reputation: 9764
Try this
@Html.TextBox(
"Login",
null,
new {
required = "required"
}
)
Upvotes: 1