I usually do this to load a web user control from the layouts directory.
protected override void CreateChildControls()
{
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
base.CreateChildControls();
string strControlReference = "/_layouts/Controls/MyCustomControl.ascx";
//instantiate the user control
MyCustomControl ucControl = (MyCustomControl)Page.LoadControl(strControlReference);
//add the control to webpart
this.Controls.Add(ucControl);
});
}
catch (Exception ex)
{
Common.WriteLogEvent(ex);
}
}
Now what I wanted to do is, I have a web form “_/layouts/Page/MyPage.aspx” file under the layouts folder and I wanted to load this file instead of loading a typical ascx file on the webpart page.
Would it be possible? I would like to know how. Thank you.
You could add an
<IFRAME>to the webpart and load the page into that.Or create the
IFRAMEprogrammatically and add it in the same way you add the user controls: