如何在asp.net 3.5中单选按钮 [英] how to radio button in asp.net 3.5
本文介绍了如何在asp.net 3.5中单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是VS2008,C#.net和Asp.net网络应用程序。
如何在网页中使用单选按钮。我正在使用2个单选按钮。一次只能检查一个单选按钮。
我查看单选按钮时,两次都被检查。希望你能理解我的问题。如何解决这个问题。
任何链接或建议将不胜感激
问候
Mukesh
Hi,
I am using VS2008,C#.net and Asp.net web application.
How can use radio button in web page. I am using 2 radio button. only one radio button should checked at a time.
while i checked radio button, both are checked at a time. hope u will understand my problem. how can resolve this issue.
any link or suggestion will be appreciated
Regards
Mukesh
推荐答案
使用GroupName
property [ ^ ]。
设置相同的GroupName
用于两个单选按钮。
另一个这里的示例 [ ^ ]。
Radiobuttons are grouped together by using theGroupName
property[^].
Set the sameGroupName
for both the radio buttons.
Another example here[^].
检查此代码。
Hi,
check this code.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1-transitional.dtd">
<script runat="server">
protected void RadioButton_CheckedChanged(object sender,System.EventArgs e) {
if (RadioButton1.Checked == true)
{
Response.Write("You Selected: Asp.Net");
}
else {
Response.Write("You Selected: ColdFusion");
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>RadioButton example: how to use RadioButton control in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButton ID="RadioButton1" runat="server" Text="Asp.Net" GroupName="Software" AutoPostBack="true" OnCheckedChanged="RadioButton_CheckedChanged" />
<asp:RadioButton ID="RadioButton2" runat="server" Text="ColdFusion" GroupName="Software" AutoPostBack="true" OnCheckedChanged="RadioButton_CheckedChanged" />
</div>
</form>
</body>
</html>
Best Luck
Happy Coding
Best Luck
Happy Coding
HI Mukesh,
尝试groupname属性radiobuton。希望它一定能帮到你。
Ajinkya S.
Web Developer。
HI Mukesh,
Try groupname property of radiobuton. Hopes it will surely help you out.
Ajinkya S.
Web Developer.
这篇关于如何在asp.net 3.5中单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文