views:

110

answers:

2

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.

A: 

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.

Jimmeh
+2  A: 
var comboHtml = '<%= Html.DropDownList("name", Model.MySelectList) %>';
Darin Dimitrov
thank you darin, would have never arrived at that one !!
kalki