Adding usercontrol each time on ButtonClick event.
Posted
by akshatrautela
on Stack Overflow
See other posts from Stack Overflow
or by akshatrautela
Published on 2010-05-13T20:33:18Z
Indexed on
2010/05/13
20:44 UTC
Read the original article
Hit count: 267
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);
}
© Stack Overflow or respective owner