I'm creating a checkbox list to handle some preferences as follows...
<ul>
<%foreach (var item in ViewData["preferences"] as IEnumerable<MvcA.webservice.SearchablePreference>)
{
var feature = new StringBuilder();
feature.Append("<li>");
feature.Append("<label><input id=\"" + item.ElementId + "\" name=\"fpreferences\" type=\"checkbox\" />" + item.ElementDesc + "</label>");
feature.Append("</li>");
Response.Write(feature);
}
%>
</ul>
The data handed to the viewdata of SearchablePreference[] and the list displays fine.
The question is; How would I repopulate the selected boxes if the page had to return itself back (i.e failed validation).
In webforms its handled automatically by the viewstate; with the other input elements I'm simply passing the sent-data back to the page via ViewData.
Thanks