1

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.

1
  • pls mark my answer as your solution if it helped you (mark an answer as accepted, click on the check mark beside the answer to toggle it from greyed out to filled in). thanks Commented Mar 30, 2016 at 12:41

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

If you want to add dynamic controls to your sub page, then i suggest you to add a panel, and then simply use panel.controls.add(your button) and thats all.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.