how to get selected index of html.dropdownlistfor
i have a dropdownlist:
<%= Html.DropDownListFor(model => model.OperatingSystem, Model.OperatingSystemDropDownBowValues, new { style = "width:142px; margin-left: 10px; font-size: 11px;" })%>
is it possible to get index of some item? i need validate a form, if first (default = "Choose...") dropdownlist item is selected(not by user) then its 开发者_JS百科not way to save other form values.
Only if you compare the submitted value with the original list, or use JavaScript/JQuery on the submission.
Can you add the value of the "Choose..." option as an empty string?
If you can set the Value of the "Choose..." then you could pick up the value return of you dropdown element isnullorempty
The [Required]
attribute should work with that being sumitted too.
Cheers
精彩评论