Click here to Skip to main content
15,907,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi how to create button programatically

Button btn = new Button();
btn.ID = "Button1";
btn.Click += new EventHandler(btn_Click); // Just an example, you must write the eventhandler yourself
btn.Text = "OK";
<Placeholder>.Controls.Add(btn); //put it on page, panel or whereever

Share this answer
You can add a control dynamically like this.

Button btn = new Button();
btn.Text = "My Button";

You can add this button to any container control like panel, placeholder etc.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900