【问题标题】:Get the selected input type radio button ASP.NET获取选定的输入类型单选按钮 ASP.NET
【发布时间】:2010-12-04 07:46:12
【问题描述】:

我有两个单选按钮:

<input type="radio" name="group1" />1
<input type="radio" name="group1" />2

我如何知道表单发布时选择了哪一个?

【问题讨论】:

    标签: asp.net html radio-button


    【解决方案1】:

    如果您使用的是 runat="server",则可能会在客户端更改 name 属性,因此您将获得 null 作为值。

    【讨论】:

      【解决方案2】:

      输入应该有值:

      <input type="radio" name="group1" value="1" />1
      <input type="radio" name="group1" value="2" />2
      

      然后,该值将发布在名称group1 上。在 Asp.net 上,您可以使用:

      Request.Form["group1"]
      

      【讨论】:

      • Request.Form["group1"] 返回 null !
      • 尝试Request["group1"] 以确保。如果这不起作用,你就发错了。
      猜你喜欢
      • 2020-07-04
      • 1970-01-01
      • 2019-03-17
      • 2018-02-07
      • 2016-09-20
      • 2011-07-28
      • 1970-01-01
      • 2012-07-31
      • 1970-01-01
      相关资源
      最近更新 更多