【问题标题】:Post multiple html checkbox to asp.net page将多个 html 复选框发布到 asp.net 页面
【发布时间】:2012-09-22 16:15:18
【问题描述】:

我想向 asp.net 提交多个 html 复选框控件,我在 php 中完成了它,这很简单,但是在 asp.net 中无法正常工作,我的 asp.net 代码就是这样

   <form id="form1" runat="server">
    <div>
        <input type="checkbox" name="checkbox[]" value="1" />
        <input type="checkbox" name="checkbox[]" value="2" />
        <input type="checkbox" name="checkbox[]" value="3" />
        <input type="checkbox" name="checkbox[]" value="4" />
        <input type="checkbox" name="checkbox[]" value="5" />
        <input type="checkbox" name="checkbox[]" value="6" />
        <input type="text" name="text" />
        <input type="submit" name="btn" value="Click" />
    </div>
    </form>
    <%
        if (Request.Form["btn"] != null)
        {
            Response.Write(Request.Form["text"]);
            Response.Write(Request.Form["checkbox"]);
        }
         %>

我使用Response.Write 呈现复选框,所以我不能在这里使用服务器控件。

【问题讨论】:

  • Request.Form 设置断点并检查密钥...也许试试Request.Form["checkbox[]"]

标签: c# asp.net html forms http-post


【解决方案1】:

尝试使用 Request.Form["checkbox[]"] 而不是 Request.Form["checkbox"]。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-16
    • 2014-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-23
    • 2012-06-24
    相关资源
    最近更新 更多