c# - HttpContext.Current.Request.Form 复选框

标签 c# asp.net asp.net-mvc-3

我将我的表单发布到 MVC Controller ,我想在其中处理用户在 html 结构等网格上所做的一些更改。

我在我的 View 中为每一行呈现了简单的 HTML 复选框:

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

我想知道如何在 AJAX 帖子后检索复选框值。

我正在尝试使用以下内容来检索

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

并且无论复选框是否被选中,我总是得到一个空值。

最佳答案

cbxR1cbxR2 应该是输入元素的名称,而不是 id。

<form ...>

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

</form>

关于c# - HttpContext.Current.Request.Form 复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18191908/

相关文章:

c# - 泛型方法返回类型作为类型参数

c# - 向 DBContext 添加重载

c# - 我应该使用 session 状态还是 FormAuthentication 来跟踪登录用户?

asp.net-mvc-3 - ASP.NET MVC3,如何对不同的用户角色使用不同的输出缓存配置文件?

asp.net - MVC中jQuery对话框中表单的常用方法

c# - C#附加信息: External component has thrown an exception

c# - ORA-01013 : user requested cancel of current operation

css - bootstrap asp.net 文本框不能正确居中

asp.net - Sourceforge 如何启动基于 javascript 的下载?

asp.net-mvc-3 - 如何阻止同一用户在另一台计算机上登录?