Sunday 26 June 2016

Add User Control dynamically in PlaceHolder on aspx Page from Code Behind.

————————-aspx  code——————
<asp:PlaceHolder runat=”server” ID=”placeHolder1″ />
—– ——————C# Code    —————————
protected void AddDynamicallyUserControl()
{
//<asp:PlaceHolder runat=”server” ID=”placeHolder1″ />
PlaceHolder placeHolder1 = this.Master.FindControl(“ControlPlaceHolder1”).FindControl(“placeHolder1”) as PlaceHolder;
if (placeHolder1 != null)
{
Control _Control = default(Control);
_Control = Page.LoadControl(“~/UserControl/Login.ascx”);
placeHolder1.Controls.Add(_Control);
}
else
{
//
}
}
Posted on

No comments:

Post a Comment