获取所选输入类型单选按钮 ASP.NET

发布于 2024-08-07 18:35:51 字数 155 浏览 2 评论 0原文

我有两个单选按钮:

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

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

I have two radio buttons:

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

How do I know which one is selected when the form is posted?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

唱一曲作罢 2024-08-14 18:35:51

输入应该有值:

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

然后,该值将发布在名称 group1 上。在 Asp.net 上,您可以使用以下方式获取它:

Request.Form["group1"]

The inputs should have values:

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

Then, the value will be posted on the name group1. On Asp.net you can get it using:

Request.Form["group1"]
七分※倦醒 2024-08-14 18:35:51

如果您使用 runat="server",则名称属性可能会在客户端发生更改,因此您将得到 null 作为值。

If you are using runat="server", it can happen that name attribute is changed at client, so you will get null as value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文