如何在服务器端关闭radwindow并刷新父页面
我想关闭RadWindow并刷新父服务器:如何执行此服务器端:
我有以下情况:
两页说:
parent.aspx:
和parent.cs
protected void OpenNewWindow(string url, int width, int height,int mode) { RadWindow newWindow = new RadWindow(); newWindow.NavigateUrl = url; newWindow.VisibleOnPageLoad = true; newWindow.KeepInScreenBounds = true; if (width > 0) { newWindow.Width = width; } if (height > 0) { newWindow.Height = height; } newWindow.VisibleStatusbar = false; if (mode == 0) { newWindow.DestroyOnClose = true; newWindow.InitialBehaviors = WindowBehaviors.Maximize; } RadWindowManager1.Windows.Add(newWindow); }
我在我的父页面上的某个gridview的rowcommand中调用此方法:
像这样 :
OpenNewWindow("child.aspx", 0, 0,0);
现在我想在服务器端单击child
页面上某个按钮的事件来关闭rad窗口并刷新父窗口如何做到这一点?
正如你所说,你想要从代码背后关闭。 所以你可以渲染Page.ClientScript.RegisterClientScriptBlock(GetType(), "CloseScript", "refreshParentPage()", true);
从代码后面刷新父。
只需在子页面中添加以下代码和脚本即可。 父页面中不需要代码。
protected void CloseButton_Click(object sender, EventArgs e) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "CloseScript", "refreshParentPage()", true); }
更新 :
// Redirect page page to url function redirectParentPage(url) { getRadWindow().BrowserWindow.document.location.href = url; } // Code behind Page.ClientScript.RegisterClientScriptBlock(GetType(), "CloseScript", "redirectParentPage('Parent.aspx')", true);
您应该使用getRadWindow().close()
方法和OnClientClose
事件。
在Child.aspx上:
在Child.cs中:
protected void btn_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(Page, typeof(Page), "closeScript", "clientClose('');", true); }
在Parent.cs中创建RadWindow时,添加OnClientClose
事件: newWindow.OnClientClose = "OnChildWindowClosed";
。
在Parent.aspx上:
强制关闭rad窗口的简单方法,只需将其置于更新面板中:
重要提示:您必须将此属性应用于更新面板:
UpdateMode =“条件”RenderMode =“Block”
然后在你想要执行close命令的按钮内执行:
UpdatePanel1.update()
这个命令将关闭radwindow,不会刷新你的网页,也不需要javascript,我试过了。