如何关闭服务器端上的radwindow并刷新父页面 [英] How to close the radwindow on serverside and refresh the parent page

查看:514
本文介绍了如何关闭服务器端上的radwindow并刷新父页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要关闭的<一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆