如何使用c#在模式对话框(弹出窗口)中打开SharePoint应用程序页面?
有时需要将SharePoint应用程序页面作为弹出窗口打开。那么,如何使用C#打开SP应用程序页面作为弹出窗口?C#代码:如何使用c#在模式对话框(弹出窗口)中打开SharePoint应用程序页面?,c#,sharepoint,sharepoint-2010,sharepoint-2013,C#,Sharepoint,Sharepoint 2010,Sharepoint 2013,有时需要将SharePoint应用程序页面作为弹出窗口打开。那么,如何使用C#打开SP应用程序页面作为弹出窗口?C#代码: void OpenApplicationPageAsPopup(){ string strWebUrl = SPContext.Current.Web.Url; string strPageURL = strWebUrl + "/_layouts/MyLayoutFolder/MyPage.aspx"; System.Web.UI.ScriptManager.Registe
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);
}
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;
}
JavaScript代码:
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);
}
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;
}
建议:您只需在客户端通过JavaScript而不是C#使用window.open(..)[在尝试打开页面(不是新的/Edit/DispView)时对我不起作用]:
在SharePoint页面上呈现功能区时发生异常。引发了以下异常:System.ArgumentException:id为“Ribbon.Read”的功能区选项卡尚未对此页面可用或不存在。请使用Ribbon.MakeTabAvailable()。