如何查找动态生成的HtmlInputCheckBox,并判断是否被选中? 如何查找动态生成的HtmlInputCheckBox(有十几个吧),并判断是否被选中? 用c#后台代码. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 foreach(Control c in this.Controls){ if(c is HtmlInputCheckBox){ HtmlInputCheckBox h =c as HtmlInputCheckBox; if(h.Checked){ //do sth}}} 不行呀,好像找不见动态生成的HtmlInputCheckBox控件。 foreach(Control c in this.Controls){if(c is HtmlInputCheckBox){HtmlInputCheckBox h =c as HtmlInputCheckBox;if(h.Checked){}}}添加runat="server" 在哪里添加runat="server"呀?这个动态生成的HtmlInputCheckBox控件是放在一个table中的、一个动态生成的行中的。table已有了runat="server" TableCell tc = new TableCell();HtmlInputCheckBox t= new HtmlInputCheckBox ();t.ID= ???tc.Controls.Add(t);这个不需要手动指定runat = "server"按楼上几位的方法应该可以的。 this .FindControl("1") as HtmlInputCheckBox用这个方法可以找见。一楼的方法也应该找见呀。为什么找不见呢?用循环如何找呀? 输出时。。给checkbox取一个名字:比如:chbAbc; $("input[name='chbAbc']:checked").each(function(){ str+=$(this).val()+","; //这里得到是所有选中checkbox的ID,用逗号隔开的 }) 用JS会好点用后台只能是在标签中加了runat="server"然后遍历页面的控件,看是不是checkbox,然后再判断是否选中。。建议还是用前台判断 WebService天气预报 如何用C#编写 纯 win32 的 ocx 怎么DrawString竖着写 请大家帮助我啊,一周啦 关于xml.Serialize的问题,比较麻烦 A.com和B.com如何共享cookie? 父容器窗体中的菜单与子窗体按钮的交互操作 有没有c#关于图形,图象编程的书? C# OpenFileDialog打开后无法选择 数据库影响了一条记录,但实际未影响 求正则表达式 页面Page_Load事件加载的问题
foreach(Control c in this.Controls)
{
if(c is HtmlInputCheckBox)
{
HtmlInputCheckBox h =c as HtmlInputCheckBox;
if(h.Checked)
{
//do sth
}
}
}
{
if(c is HtmlInputCheckBox)
{
HtmlInputCheckBox h =c as HtmlInputCheckBox;
if(h.Checked)
{}
}
}
添加runat="server"
这个动态生成的HtmlInputCheckBox控件是放在一个table中的、一个动态生成的行中的。table已有了runat="server"
TableCell tc = new TableCell();
HtmlInputCheckBox t= new HtmlInputCheckBox ();
t.ID= ???
tc.Controls.Add(t);这个不需要手动指定runat = "server"按楼上几位的方法应该可以的。
一楼的方法也应该找见呀。为什么找不见呢?
用循环如何找呀?
$("input[name='chbAbc']:checked").each(function(){
str+=$(this).val()+","; //这里得到是所有选中checkbox的ID,用逗号隔开的
})