I have a form that respond to a submit button.
I have my drop down list on menu as following:
@Html.DropDownList("State", new List<SelectListItem>
{
new SelectListItem { Text = "Please select" },
new SelectListItem { Value = "AL", Text="Alabama" }, ....
new SelectListItem { Value = "WY", Text="Wyoming" })
How can I get the selected value as bool or preferably as string in my model ..
I need to validate
[Required(ErrorMessage = "Please select a state.")]
public string/bool State { get; set; }
Please help.
Thanks
You want to use a model-bound helper
and then