我在 Aspx 页面上有一个项目列表,为了编辑每个项目,我启动了 SP.UI.ModalDialog 弹出窗口来执行此操作,在此弹出窗口中创建一个提交按钮以保存更改,然后关闭弹出窗口上窗:
protected void Submit_onclick(Object sender, EventArgs e)
{
SPSecurity.RunWithElevatedPrivileges(delegate
{
try
{
using (SPSite mySite = new SPSite(PGContext.Site.ID))
{
using (SPWeb myweb = mySite.OpenWeb(PGContext.Web.ID))
{
myweb.AllowUnsafeUpdates = true;
//changes
myweb.AllowUnsafeUpdates = false;
Page.ClientScript.RegisterStartupScript(this.GetType(), "closeWindow", "window.close()", true);}
}
}
catch (Exception exp)
{
throw new Exception("ERROR: Unable to Save Changes : " + exp.Message.ToString(), exp);
}
});
}
但是 Page.ClientScript.RegisterStartupScript() 似乎不起作用!我在 msdn 上查看过它,它说我只能在 Page_Load() 函数上使用它,那么如何从事件中的代码中关闭我的弹出窗口?
最佳答案
试试这个:
Response.Write("<script type='text/javascript'>window.frameElement.commitPopup();</script>");
Response.Flush();
Response.End();
关于javascript - 从后面的代码关闭 SP.UI.ModalDialog PopUp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13526572/