Context.Request.Form - Get Unchecked Checkboxes

984 views Asked by At

Is there any way to get all checkboxes using context.request ?

It has only checked checkboxes its keys collection. I need the "unchecked" checkboxes also.

I cannot rely on checkbox name. It can have any name, and I am handling it in a handler. Otherwise, if context.Request.Form.Get("checkbox1") returns Nothing then it is unchecked.

But, name of the checkbox is not pre-defined.

Any solution ?

Sample Code:

HTML Code:

<input type="checkbox" name="checkbox1"> One<br>
<input type="checkbox" name="checkbox2"> Two<br>
<input type="checkbox" name="checkbox3"> Three<br>

On submit, it will call the handler where I need to process. I do not design this HTML pages, but the code will be like this.

Handler Code:

For Each s As String In context.Request.Form
   ControlValue = IIf(context.Request.Form(s) IsNot Nothing, context.Request.Form(s), "")
Next

Here, unchecked checkboxes will not be present in context.Request.Form.

0

There are 0 answers