I am using asp.net mvc, and try to submit a selected list with the HtmlHelper.DropDownListFor method I'm doing this:
& lt;% = Html.DropDownListFor (x = & gt; x.AllTopics, SelectListHelper.GetSelectListItems (Model.AllTopics), "Choose a topic", new {id = "Allotics", @ class = "topic-dropdown"})%>
Where selectListHelper is just a IList & lt; SelectListItem & gt;
gives us whatever we are going through. It works fine for simple things, but I want to be able to add a title attribute to each option tag ( no select list) But DropDownListFor only one IEnumerable & lt; SelectListItem & gt;
, and there is no place in the SelectListItem that I can add to the title attribute.
Is there any way to do this by putting the DropDownListFor method in the foregoing and selected list and handwriting each element?
Dropdown list and derivative don 'Do not support the functionality you are looking for. But you can only process the string returned by the dropdown list.
& lt;% = html.DropDownListFor (x = & gt; x.AllTopics, SelectListHelper.GetSelectListItems (Model.AllTopics), "Select a topic (" option "," & Lt; option attr = \ "value \" "%)" and "% 1"
No comments:
Post a Comment