I created a user control that basically consists of 3 text fields. I want to allow the user to click a hyperlink that will add a new instance of the user control to PlaceHolder. This seems to work when I populate one of the textbox controls with a random number, which changes whenever I click on the hyperlink. However, this overwrites the previous control.
Here is the code on MyPage.aspx
protected void MyHyperlink_Click(object sender, EventArgs e)
{
var uc = new MyUserControl();
uc = (MyUserControl)LoadControl("~/path/to/my/usercontrol.ascx");
placeHolderCtrl.Controls.Add(uc);
}
Basically, I need to know how I can get a control that adds different instances under eachother, because it just seems like every control is overwritten every time.
Thanks.
James source
share