代码:
CheckBox cb;
cb = new CheckBox();
cb.Text = TextBox2.Text;
Panel3.Controls.Add(cb);
只能添加进去一条。不能添加多个。在Page_Load里写的
asp.net 动态添加checkbox,会覆盖上一条
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
斯洛文尼亚旅游 2017-04-14 04:51关注完全没问题。。
<%@page language="C#" Debug="true" ValidateRequest="false"%> <script runat="server"> protected void Page_Load(object sender,EventArgs e) { CheckBox cb; cb = new CheckBox(); cb.Text = "abc"; Panel3.Controls.Add(cb); cb = new CheckBox(); cb.Text = "abc2"; Panel3.Controls.Add(cb); } </script> <html> <head> </head> <body> <form runat="server" method="post"> <asp:Panel runat="server" ID="Panel3"><asp:CheckBox ID="cb1" runat="server" /></asp:Panel> </form> </body> </html>解决 无用评论 打赏 举报