【问题标题】:how to use request.form by the id of element not by nam in c#如何在c#中通过元素的id而不是nam使用request.form
【发布时间】:2017-05-08 08:16:28
【问题描述】:

我在字段集中有一些具有相同名称的单选按钮
可以一次选择一个
如何通过 id 而不是名称在代码中访问它们,因为它们都具有相同的名称

          <fieldset id="group1">
            <input type="radio" name="group1"  id="google" checked runat="server" value ="google"/>
            <label for="google" id="Label1">1th  SE</label>
            <input type="radio" name="group1"  id="yahoo" runat="server" value ="yahoo"/>
            <label for="yahoo">2th SE</label>

            <input type="radio" name="group1" id="bing" runat="server" value ="bing" />
            <label for="searchSite" id="Label2">3th SE</label>&nbsp;
            <input type="radio" name="group1"  id="ask" runat="server" value ="ask" />
            <label for="ask">4th SE
            </label>
            <input type="radio" name="group1"  id="mse" runat="server" value ="mse" />
            <label for="ask">5th SE
            </label>

           </fieldset>

【问题讨论】:

  • 您的表单/单选按钮的 HTML 代码是否已分类?
  • 我添加了html代码

标签: c# asp.net forms radio-button


【解决方案1】:

如果您只使用 HTML 元素 Request.Form["group1"] 应该适合您。它将返回所选选项的value:google、yahoo 等

【讨论】:

    猜你喜欢
    • 2012-08-06
    • 2014-05-29
    • 2015-07-29
    • 1970-01-01
    • 1970-01-01
    • 2010-10-08
    • 1970-01-01
    • 2015-04-01
    • 2012-12-06
    相关资源
    最近更新 更多