Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpContext.Current.Request.Form checkbox

I am posting my form to an MVC Controller, where I want to process some changes the user has made on a grid like html structure.

I have checkboxes rendered as simple HTML in my View for each row :

<input type="checkbox" id="cbxR1" checked="checked" />
<input type="checkbox" id="cbxR2" checked="checked" />

I would like to know how I would retrieve a checkbox value after an AJAX post.

I am trying to use the following to retrieve the

HttpContext.Current.Request.Form["cbxR1"]

and am always getting a null, regardless of whether the checkbox was checked or not.

like image 487
TK1 Avatar asked Jun 16 '26 05:06

TK1


1 Answers

The cbxR1, cbxR2 should be the name of an input element, not the id.

<form ...>

<input type="checkbox" name="cbxR1" checked="checked" />
<input type="checkbox" name="cbxR2" checked="checked" />

</form>
like image 80
AgentFire Avatar answered Jun 17 '26 22:06

AgentFire