如何使用c#在模式对话框(弹出窗口)中打开SharePoint应用程序页面?

时间:2015-01-11 05:01:29

标签: c# sharepoint sharepoint-2010 sharepoint-2013

有时需要打开SharePoint应用程序页面作为弹出窗口。那么如何使用C#打开SP应用程序页面作为弹出窗口?

1 个答案:

答案 0 :(得分:0)

C#代码:

void OpenApplicationPageAsPopup(){
string strWebUrl = SPContext.Current.Web.Url;
string strPageURL = strWebUrl + "/_layouts/MyLayoutFolder/MyPage.aspx";
System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), ClientID, "ExecuteOrDelayUntilScriptLoaded(openModelDialogPopup('" + strPageURL + "'), \"SP.js\");", true);

}

JavaScript代码:

function openModelDialogPopup(strPageURL ) {

    var dialogOptions = {
        title: "This is Modal Dialog", //Popup title.
        url: strPageURL, 
        width: 600, // Width of the dialog.
        height: 400
    };
    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', dialogOptions);
    return false;
}