In Part #1, I described a method signature for the Html.DropDownListFor
static HtmlHelper
method, which was:
@Html.DropDownListFor(m => m.UserId, m => m.UserNames, m => m.Id, m => m.Name)
In this part. I’ll write more about HtmlHelper
extension method code to make this work. That’s how you use it in Razor – but what does this method signature look like in the source code? Each of the lambda expressions in the above method signature is an expression which is represented by Expression<Func<T1, T2>> expr.
The first parameter will represent the name of the form field rendered, i.e. what the Id
and Name
values are for the Html <select> element. The second parameter represents the items in the <select>
list. The third parameter is the property in the items from the above list which should be rendered in the value attribute of each of the <option>
elements of the <select>
list. The fourth parameter is the property in the items from the above list which…
View original post 678 more words
Leave a Reply