复选框选择示例 [英] checkbox selection example
本文介绍了复选框选择示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在存在多个复选框的情况下,如何选择单个复选框...
how can i select the single check while multiple check box are present...
推荐答案
Default.aspx
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem>Swaminarayan-BAPS</asp:ListItem>
<asp:ListItem>Microsoft</asp:ListItem>
<asp:ListItem>Apple</asp:ListItem>
<asp:ListItem>Oracle</asp:ListItem>
<asp:ListItem>IBM</asp:ListItem>
</asp:CheckBoxList>
</div>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<p>
<asp:TextBox ID="TextBox1" runat="server" Height="165px" TextMode="MultiLine"
Width="242px"></asp:TextBox>
</p>
</form>
</body>
</html>
================================================== =======================
Default.aspx.cs
==========================================================================
Default.aspx.cs
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text ="";
foreach(ListItem lst in CheckBoxList1.Items)
{
if(lst.Selected==true)
TextBox1.Text += lst.Text + "\n";
}
}
}
现在,只需使用if()&进行更改或添加其他竞争条件即可.修改.现在是如此简单
Now simply make change or add another contidtion with the if() & modify.It''s so easy now
这篇关于复选框选择示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文