ASP.NET:
<asp:Panel ID="pnlFilter" runat="server">
<div class="dvFilter">
<input type="checkbox" id="cb01" checked="checked" />
<label for="cb01">All</label>
</div>
<div class="dvFilter">
<input type="checkbox" id="cb02" checked="checked" />
<label for="cb02">None</label>
</div>
</asp:Panel>
C#:
foreach (Control item in this.form1.Controls)
{
System.Web.UI.HtmlControls.HtmlInputCheckBox _cbx = item as System.Web.UI.HtmlControls.HtmlInputCheckBox;
if (_cbx != null)
{
if (_cbx.Checked)
{
//Do something:
Response.Write(_cbx.Name + " was checked.<br />");
}
}
}
I am getting a null
value for the _cbx
variable.
How can I update it so I am able to get the ID of all the checked
input type checkboxes.
I tried this answer: Count the number of TextBoxes and CheckBoxes in a form but didn't work for me either.