如何关闭服务器端上的radwindow并刷新父页面 [英] How to close the radwindow on serverside and refresh the parent page
问题描述
我要关闭的<一个href=\"http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx\">RadWindow并刷新父:如何做到这一点的服务器端:
I want to close the RadWindow and refresh the parent : how to do this server side :
我有以下情况:
两页说:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableViewState ="false">
</telerik:RadWindowManager>
和parent.cs
and 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);
}
我称之为我的parentpage一些GridView控件的rowcommand此方法:
i call this method in the rowcommand of some gridview on my parentpage :
是这样的:
OpenNewWindow("child.aspx", 0, 0,0);
现在我想上的子的一些按钮的服务器端Click事件
页面关闭RAD窗口并刷新父一个人如何做到这一点?
Now i want on the server side click event of some button on the child
page to close the rad window and refresh the parent one how to do this ??
推荐答案
正如你所说,你想从code紧随其后。所以,你可以渲染 Page.ClientScript.RegisterClientScriptBlock(的GetType(),CloseScript,refreshParentPage(),真正的);
从code背后刷新父
As you said, you want to close from code behind. So you can render Page.ClientScript.RegisterClientScriptBlock(GetType(), "CloseScript", "refreshParentPage()", true);
from code behind to refresh the parent.
只需添加以下code和脚本在子页面。需要在父页面没有code。
Just add the following code and script in Child Page. No code is needed in parent page.
<script>
function getRadWindow() {
var oWindow = null;
if (window.radWindow)
oWindow = window.radWindow;
else if (window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
return oWindow;
}
// Reload parent page
function refreshParentPage() {
getRadWindow().BrowserWindow.location.reload();
}
</script>
<asp:Button runat="server" Text="Close" ID="CloseButton"
OnClick="CloseButton_Click"/>
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);
这篇关于如何关闭服务器端上的radwindow并刷新父页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!