Adding usercontrol each time on ButtonClick event.
- by akshatrautela
I am trying to add an instance of UserControl each time on button_click event, it works for the first time only. I am adding IDs to user control by appending integers from ViewState.
Why does it not add work for subssequent clicks. Here is the simplified version with the same behavoir.
protected void Button1_Click(object sender, EventArgs e)
{
HtmlButton btnClick = new HtmlButton();
btnClick.ID = "bt" + Append.ToString();
btnClick.InnerText = "Button 1";
MainArea.Controls.Add(btnClick);
}