HttpContext.Current.Request.Form复选框 [英] HttpContext.Current.Request.Form checkbox

查看:523
本文介绍了HttpContext.Current.Request.Form复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我张贴我的形式,以一个MVC控制器,在这里我要处理一些改变用户已经像HTML结构网格的。

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.

我在查看呈现为简单的HTML每一行的复选框:

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" />

我想知道我怎么会一个AJAX POST之后检索一个复选框值。

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.

推荐答案

cbxR1 cbxR2 应该是命名输入元素,而不是身份证。

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>

这篇关于HttpContext.Current.Request.Form复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆