I do not know how to add controls dynamically to the form using C# .net. Can anyone help me? I know this with vb.net but I need to know the syntax in C#.
In Aspx
<%@ Reference Control = "WebUserControl1.ascx" %>
U can use the following in the Cs file to laod the control dynamically...
if (case)
else
{
WebUserControl1 uc =
(WebUserControl1) Page.LoadControl("WebUserControl1.ascx");
PlaceHolder1.Controls.Add(uc);
}
or try this
Content.Controls.Add(Page.LoadControl("UserControls/InventoryNav.ascx"));
Can also have a look at:
http://aspalliance.com/565
http://samuelmueller.com/2008/12/dynamicloader-plugin-dynamically-loading-asp-net-user-controls-with-jquery
http://forums.asp.net/p/1222567/2826338.aspx