:::: MENU ::::

Adding a prompt option to Html.Select in ASP.NET MVC

Digging around the source code to the ASP.NET MVC Source Refresh, I discovered a useful extension to the Html.Select helper method.

Say you want a select dropdown with a NULL case, which instructs the user to make a selection.

Eg: You want your first option to be:  ==Select==

To do so, call Html.Select with a htmlAttribute of prompt=”==Select==”


<%=Html.Select((“Quote.ClientId”), ViewData.Clients, “Name”,”Id”, ViewData.Quote.ClientId,0,false,new {prompt=”==Select==”})%>

So, what do you think ?