validate dropdown field in asp.net mvc 3 razor -
code is:
@using (html.beginform("register", "user", formmethod.post, new { id = "registerform" })) {
@html.dropdownlist("stateid", new selectlist(model.states, "stateid", "statename"), "--select option--", new { @tabindex = "11" })
}
i need required field validation dropdown
have tried using data annotations in model mark property required?
[required(errormessage = "you must select state")]
are exposing stateid
part of model? if that's should set required attribute, so:
[required(errormessage = "you must select state")] public int stateid { get; set; }
Comments
Post a Comment