how hoop checkboxes asp.net mvc forms?
caution: doubt over 9 years old!
your best choice hunt newer questions, hunt answers next looking your specific chronicle mvc, answers here obsolete now.
if an answer works your version, greatfully certain answer contains chronicle mvc using.
(the uncanny doubt starts below)
this seems bit uncanny me, nonetheless distant i tell, it.
i have collection objects, i wish users name some-more them. says me "form checkboxes." objects don't have any visualisation "selected" (they're easy poco's shaped deserializing wcf call). so, i following:
public category sampleobject{
open guid id {get;set;}
open twine name {get;set;}
}
in view:
<%
controlling (html.beginform())
{
%>
<%foreach (var o viewdata.model) {%>
<%=html.checkbox(o.id)%> <%= o.name %>
<%}%>
<input type="submit" value="submit" />
<%}%>
and, controller, wholly proceed i figure out objects user checked:
public actionresult thislooksweird(formcollection result)
{
var winnars = x result.allkeys
where result[x] != "false"
name x;
// yadda
}
its freaky initial place, secondly, those equipment user checked, formcollection lists the value "true false" rather only true.
obviously, i'm blank something. i cruise built thought mind objects collection acted on within html form updated controlling updatemodel() by modelbinder.
but objects aren't set adult this; does meant wholly way? there another proceed it?
Comments
Post a Comment