Is there a way to output select list to a string in the View ?
//Javascript
var comboHtml = <%= Html.Encode(Model.MySelectList.ToHtml()) %>
or would i have to enumerate the list my self to create the html,
need this for a dynamic form field.
Is there a way to output select list to a string in the View ?
//Javascript
var comboHtml = <%= Html.Encode(Model.MySelectList.ToHtml()) %>
or would i have to enumerate the list my self to create the html,
need this for a dynamic form field.
You could use ajax and Html.RenderPartial.
(assuming mvc.net btw)
Also, the issue with doing it in Javascript is that the <%= stuff here %> would render the string at the page load.
var comboHtml = '<%= Html.DropDownList("name", Model.MySelectList) %>';