checkbox.aspx

来自「ASP.NET精彩编程百例」· ASPX 代码 · 共 46 行

ASPX
46
字号
<Script Language="C#" Runat="Server">
public void Sub_Click(Object src,EventArgs e)
{
	string Resulte = null;
	if(chk1.Checked==true)
	{
		Resulte = Resulte + "您选择中了Marry<br>";
	}
	if(chk2.Checked==true)
	{
		Resulte = Resulte + "您选择中了John<br>";
	}
	if(chk3.Checked==true)
	{
		Resulte = Resulte + "您选择中了Tom<br>";
	}
	if(chk4.Checked==true)
	{
		Resulte = Resulte + "您选择中了Susan<br>";
	}
	if(chk5.Checked==true)
	{
		Resulte = Resulte + "您选择中了Smith<br>";
	}
	lblShow.Text = Resulte;
}
</script>
<html>
<head>
<title></title>
</head>
<body>
   <H3>使用CheckBox控件</h3> <Hr>
<form runat="server">
<asp:CheckBox id="chk1" Text="Marry" runat="server" />
<asp:CheckBox id="chk2" Text="John" runat="server" />
<asp:CheckBox id="chk3" Text="Tom" runat="server" />
<asp:CheckBox id="chk4" Text="Susan" runat="server" />
<asp:CheckBox id="chk5" Text="Smith" runat="server" />
<asp:Button Text="提交" OnClick="Sub_Click" runat="server" />
<hr>
<asp:Label id="lblShow" runat="server" />
</form>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?