I want to add dynamically button in html table.
I created a master page and another subpage.
On the sub page, I want to dynamically add a button in html table.
This is my code:
Button btnSend = new Button();
btnSend.ID = "btnSend";
btnSend.Text = "Send";
btnSend.Click += new System.EventHandler(btnSend_Click);
this.form1.Controls.Add(btnSend);
But I get an error:
form1 is not accessible from sub page.
Please help me to dynamically add a button into the html table.
If you use asp.net then you have no forms. So simply insert a button from the toolbox and set buttonName.visible = true
or false
as you need.
如果要向子页面添加动态控件,那么我建议您添加一个面板,然后只需使用panel.controls.add(您的按钮)即可。
Do you create the HTML table on codebehind? If so, you may add the button there. If not, you may try putting a Literal there, and fill it with the code for an HTML button if needed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.