code is:
@using (Html.BeginForm(“Register”, “User”, FormMethod.Post, new { id = “RegisterForm” }))
{
@Html.DropDownList("StateId", new SelectList(Model.States, "StateId", "StateName"),
"--Select an option--", new { @tabindex = "11" })
}
i need required field validation for dropdown
Have you tried using Data Annotations in your model to mark the property as required?
Are you exposing the
StateIdas a part of the Model? If so that’s where you should set the Required Attribute, like so: