Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用c#在模式对话框(弹出窗口)中打开SharePoint应用程序页面?_C#_Sharepoint_Sharepoint 2010_Sharepoint 2013 - Fatal编程技术网

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

如何使用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

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

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);

}
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()。