Home > Forum > C# > I want to add dynamic buttons on page load method

I want to add dynamic buttons on page load method

by Thamil   on Oct 27, 2014   Category: C#  |  Views: 890    |  Points: 5   |  Gold 
  Reply

I wanna to add dynamic buttons on page load and display the buttons name from database. I have to use c# code to go through it.. Please help me out.

Question Posted on behalf of Namrata.

Bookmark and Share:
 
  User Reply  | Ask a question  |   Reply 
  Re :I want to add dynamic buttons on page load method   
by Thamil
on Oct 27 2014 1:52AM
Points : 10
Gold 
Hi Namrata,

Please refer the below to create the dynamic button
protected void Page_Load(object sender, EventArgs e)
{
AddControls();
}

private void AddControls()
{
Button btndynamic = new Button();
btndynamic.Click += new System.EventHandler(btndynamic_Click);
btndynamic.Text = "Submit";
PnlArea.Controls.Add(btndynamic); //Add the Panel in the aspx page
}

private void btndynamic_Click(Object sender, System.EventArgs e)
{
//Your code here.
}


Thanks

Recent Post

Latest Posts