Monday, December 20, 2010

Don't forget the colon on ASP.NET MVC Html helpers!

Note to self: On ASP.NET MVC 2, when using Html helpers, like Html.DropDownListFor, they don't work if you leave out the colon after the opening "crow's beak".

This won't work:

<% Html.DropDownListFor(model => model.Country, ViewData["Countries"] as SelectList) %>

This will:

<%: Html.DropDownListFor(model => model.Country, ViewData["Countries"] as SelectList) %>

No comments: