Get Value from Checkbox
Hello I can not predenrmi all values of the checkboxes on the screen. Let me explain, I have 5 checkboxes for example 2 are enhanced not the others I'd like an array with all 5 checkboxes including 2 true and others false Someone can help me.
in the meantime I tried to do another system I have created a class
public class PresenzaAO
(
public List <Presenti> listapresenti = new List <Presenti> ();
public string conteggiototale (get;)
public long idalunno (get;)
public string radio (get;)
)
public class Present
(
public string presents{get;set;}
)
and then in the view I created this:
<% Using (Html.BeginForm (ModificaPresenzaAlunno "," Presence ", FormMethod.Post))
(%>
<% = Html.Hidden ( "conteggiototale" Viewdata [ "conteggiototale"])%>
<% = Html.Hidden (idalunno "Viewdata [" student "])%>
<table>
<tr>
<td>
<% = Html.Encode (nomealunno)%>
</ td>
<td>
<% = Html.Encode (cognomealunno)%>
</ td>
<%
if (Viewdata [ "conteggio_presenze"]. ToString () == Viewdata ["conteggiototale"]. ToString ())
(%>
<td>
Absent
<input type = "radio" name = "radio" checked 开发者_开发问答= "checked" id = "assente_"
onclick = "getassentemod (<% = Viewdata [" student "]%>, 0);" value = "true_assente" />
This
<input type = "radio" name = "radio" id = "presente_" value = "false_presente"
onclick = "getassentemod (<% = Viewdata [" student "]%>, 0);" />
</ td>
<% Int i = 0;%>
<% Foreach (var p in (List <PresenzaAlunnoOra>) Viewdata [ "presenze_alunno"])
(
i + = 1;
%>
<td>
<input type = "checkbox" id = "check_ <% = Viewdata [" student "] %><%= i%>" value ="<%= i%> "name =" Present "
onclick = "modificapresenzaalunno (this);" />
</ td>
<%)%>
<%)
else
(%>
<td>
Absent
<input type = "radio" value = "false_assente" name = "radio" id = "assente_ <% = Viewdata [" student "]%>"
onclick = "getassentemod (<% = Viewdata [" student "]%>, 0);" />
This
<input type = "radio" value = "true_presente" name = "radio" checked = "checked" id = "presente_ <% = Viewdata [" student "]%>"
onclick = "getpresentemod (<% = Viewdata [" student "]%>, 0);" />
</ td>
<% Int i = 0;%>
<%
foreach (var p in (List <PresenzaAlunnoOra>) Viewdata [ "presenze_alunno"])
(
i + = 1;
if (p.presente == true)
(
%>
<td>
<input type = "checkbox" id = "check_ <% = Viewdata [" student "] %>,<%= i%>" name = "Present"
checked = "checked" value ="<%= i%> "onclick =" modificapresenzaalunno (this); "/>
</ td>
<%)
else
(%>
<td>
<input type = "checkbox" id = "check_ <% = Viewdata [" pupil "]%>,<%= i%> "value ="<%= i%>" name = "Present"
onclick = "modificapresenzaalunno (this);" />
</ td>
<%)%>
<%)%>
<%)%>
</ tr>
</ table>
<input type="submit" id="btnupdatealunni" value="modifica presenze" />
<%)%>
</ asp: Content>
place the controller parameter PresenzaAO presence
I read all the parameters except the checkbox
No, it does not contain spaces, but I noticed that in the example posted in the name of the checkbox is missing something say the name of the checkbox should look like this:
<input type = "checkbox" id = "check_ <% = Viewdata [" pupil "]%>,<%= i%> "value ="<%= i%>" name = "Present [<% = i% >].presents"
onclick = "modificapresenzaalunno (this);" />
But I do not work even
精彩评论