Here is a detailed example on
Adding Controls to an ASP.NET form Dynamically
What they do in that example is to create a PlaceHolder control called DynamicControlsHolder where some controls are added when the user clicks on the AddControlButton
<form id="form1" runat="server">
<div>
<asp:Button ID="AddControlButton" runat="server" Text="Add Control" onclick="AddControlButton_Click" />
<br />
<asp:PlaceHolder ID="DynamicControlsHolder" runat="server"></asp:PlaceHolder>
<br />
<br />
<asp:Button ID="Submit" runat="server" Text="Submit Form" onclick="Submit_Click" />
<br />
........
</div>
</form>
And then in the code behind they react to the AddControlButton being clicked
protected void AddControlButton_Click(object sender, EventArgs e)
{
TextBox txt = new TextBox();
DynamicControlsHolder.Controls.Add(txt);
DynamicControlsHolder.Controls.Add(new LiteralControl("<br>"));
}
this.Controls.Add(btnSave); but that's not all; if you attach events :D ...you guessed right, more pain is coming ;) (depending on where you are adding that control to the page)