简体   繁体   中英

Close telerik radwindow from server side in C#?

I created loading window with telerik radwindow but I am not able close it from server side in C#.

Could anyone help me?

protected void bt_next_Click(object sender, EventArgs e)
{
    string script = "function f(){ window.radopen(\"\", \"windows_loading\");Sys.Application.remove_load(f); }Sys.Application.add_load(f);";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);

    //here i connect with database and insert all info to database and then i want close the radwindow.

}

You can achieve the desired functionality like this, Server Side (ie button click etc):

System.Web.UI.ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "CloseRadWindow();", true);

Then on Client Side use these Jquery Methods:

function CloseRadWindow() {
    //get a reference to the current RadWindow
    var wndow = GetRadWindow();
    wndow .Close();
}

function GetRadWindow() {
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

this worked fro me:

aspx:

  <asp:Button ID="Button1" runat="server" Text="Save" OnClick="Button1_Click" />

aspx script:

<script type="text/javascript">


    function GetRadWindow() {
        var oWindow = null;
        if (window.radWindow)
            oWindow = window.radWindow;
        else if (window.frameElement && window.frameElement.radWindow)
            oWindow = window.frameElement.radWindow;
        return oWindow;
    }


    function CloseModal() {
        GetRadWindow().close();

    }



</script>

aspx.cs:

ClientScript.RegisterStartupScript(GetType(), "Javascript", "setTimeout(function(){ CloseModal(); },250);", true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM