Showing posts with label HTML helpers. Show all posts
Showing posts with label HTML helpers. Show all posts

Monday, April 27, 2009

ASP.NET MVC Html.DropDownList

It took me a little while to figure out how to add custom items to an ASP.net MVC Html dropdownlist.  

It takes an IEnumerable of type SelectedList, not just any IEnumerable.  What I had to do was create a List and then make a SelectedList and put that List in the selected list for it to work.

Like this:


Friday, April 17, 2009

ASP.NET MVC HTML helpers attributes

In order to set attributes for html elements using
"Html.ActionLink(, , , )"

The attributes should be like
new { @attribute=value, ...})

an example of this would be:
new { @id=doneID, @class="invisible"})

The "doneID" is a string variable that was defined earlier in the ' ' of the page.
The @class value is just a string.