6

RadWindowを閉じて、親を更新したい:このサーバー側の実行方法:

私は次の場合があります:

2ページは言う:

parent.aspx:

<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableViewState ="false">
</telerik:RadWindowManager>

および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);
        }

親ページのグリッドビューのrowcommandでこのメソッドを呼び出します:

このような :

OpenNewWindow("child.aspx", 0, 0,0);

今、私はサーバー側でchildページ上のいくつかのボタンのクリックイベントでradウィンドウを閉じ、親を更新したいのですが、これを行う方法は??

4

3 に答える 3

8

あなたが言ったように、あなたはコードビハインドから閉じたいと思っています。Page.ClientScript.RegisterClientScriptBlock(GetType(), "CloseScript", "refreshParentPage()", true);したがって、コードビハインドからレンダリングして親を更新できます。

子ページに次のコードとスクリプトを追加するだけです。親ページにコードは必要ありません。

<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);
于 2013-03-26T15:48:16.983 に答える
6

getRadWindow().close()メソッドとOnClientCloseイベントを使用する必要があります。

Child.aspxの場合:

<script type="text/javascript">

    function getRadWindow() {
        var oWindow = null;

        if (window.radWindow) 
            oWindow = window.radWindow;
        else if (window.frameElement.radWindow) 
            oWindow = window.frameElement.radWindow;

        return oWindow;
    }

    function clientClose(arg) {   
        getRadWindow().close(arg);
    }

</script>

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で:

<script type="text/javascript">

    function OnChildWindowClosed(sender, eventArgs) {
        document.location.reload(); // there may be a cleaner way to do the refresh
    }

</script>
于 2013-03-26T15:32:38.110 に答える
-1

radウィンドウを強制的に閉じる簡単な方法は、次のように更新パネル内に配置するだけです。

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="Block">
  <ContentTemplate>
     <telerik:RadWindow ID="RadWindow1" runat="server">
       <ContentTemplate>

       </ContentTemplate>
    </telerik:RadWindow>
  </ContentTemplate>
</asp:UpdatePanel>

重要:このプロパティを更新パネルに適用する必要があります:

UpdateMode = "Conditional" RenderMode = "Block"

</ p>

次に、閉じるコマンドを実行するボタン内で次のコマンドを実行します。

UpdatePanel1.update()

このコマンドはradwindowを閉じ、Webページを更新せず、javascriptも必要ありません。試してみました。

于 2016-09-24T19:41:47.663 に答える