我通常這樣做是爲了從layouts目錄加載一個web用戶控件。如何將一個aspx頁面加載到webpart中
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);
}
}
現在我想要做的是,我有一個web表單「_ /佈局/頁/ MyPage.aspx」佈局文件夾下的文件,我想加載該文件,而不是加載一個典型的ascx文件在webpart頁面上。
會有可能嗎?我想知道如何。謝謝。
我正在尋找一個解決方案,如果可能的話,不會使用iframe。但是,不知何故,這對我的問題有很大的幫助。直到明天,我會等待更好的答案。如果我沒有看到更好的答案,那麼我會將其標記爲答案:) –