c#中如何把选中的checkbox的文本显示到对话框(选中多项)
2个回答
展开全部
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string str = "";
foreach (Control c in this.form1.Controls)
{
if (c is CheckBox)
if (((CheckBox)c).Checked)
str += ((CheckBox)c).Text+" ";
}
Response.Write("<script>alert(\""+str+"\");</script>");
}
}
还一种方法就是在js里面写,思路是一样的,我就不再多写一次了
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string str = "";
foreach (Control c in this.form1.Controls)
{
if (c is CheckBox)
if (((CheckBox)c).Checked)
str += ((CheckBox)c).Text+" ";
}
Response.Write("<script>alert(\""+str+"\");</script>");
}
}
还一种方法就是在js里面写,思路是一样的,我就不再多写一次了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询