Link to home
Start Free TrialLog in
Avatar of ToString1
ToString1

asked on

Mandatory selection for dropdown list in asp.net MVC 2

I have a strongly typed view populated from viewmodel that has dropdown list.

 <%= Html.DropDownList("ID", Model.custList, "--select--")%>
  <%= Html.ValidationMessage("ID")%>

Which passes id to controller

public ActionResult Submit((int? ID)



I want to make dropdown mandatory so user must select an option
<%= Html.DropDownList("ID", Model.customereList, "--select--")%>

Open in new window

Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

If it's mandatory you could just take out the "--select--" option and default to the first option in the list instead.
Avatar of ToString1
ToString1

ASKER

Hi

No I need the select option as this is a request from the client
ASKER CERTIFIED SOLUTION
Avatar of Avodah
Avodah
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial