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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -