I am creating dynamic controls, in that one control is a button. I used the following code to add the button control.
Button btnContinue = new Button();
btnContinue.Attributes.Add("class", "button");
btnContinue.ID = "btnContinue";
btnContinue.Text = "Continue";
btnContinue.CausesValidation = false;
btnContinue.Click += new EventHandler(btnContinue_Click);
lineAdd.Controls.Add(btnContinue);
And the button click event as below.
protected void btnContinue_Click(object sender, EventArgs e)
{
...
}
This event is not firing. Any idea why this is not firing the event. Please correct me if i am wrong.
Thanks in Advance.
Page_LoadWill not create the button and link up events correctly. Make sure you put your code into thePage_Init(object sender, EventArgs e)method, if it doesn't exist in your page, create it. ( You should be able to use override )