Reputation: 44352
I have several checkboxes in a form. These are not server side checkboxes. When any box is checked, it never comes across in the form post. I'm using the following:
foreach (string key in Request.Form.AllKeys)
{...}
Any example checkbox is in this format:
<input id="chkFirstName" type="checkbox"/>
Any ideas what I'm doing wrong?
Upvotes: 0
Views: 1929
Reputation: 155463
You haven't set the name=""
or value=""
attributes on your <input />
element. The id
attribute is only used client-side, whereas the name=""
attribute corresponds to the Request field set, finally an input element must have a value for it to be submitted too.
If you're using WebForms, then use ASP.NET Controls (either <input runat="server" />
or <asp:CheckBox />
) to take advantage of stronger-typing, validation, and other benefits.
Upvotes: 0
Reputation: 219884
You're missing the name
attribute. It is required to submit its value. The id
attribute does not doe this.
<input id="chkFirstName" name="chkFirstName" type="checkbox"/>
Upvotes: 3