在C#中从服务器端关闭telerik radwindow?

时间:2015-06-04 11:53:05

标签: c# asp.net telerik

我使用telerik radwindow创建了加载窗口,但是我无法在C#中从服务器端关闭它。

有人可以帮助我吗?

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.

}

2 个答案:

答案 0 :(得分:2)

您可以实现这样的所需功能, 服务器端(即按钮点击等):

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

然后在客户端使用这些Jquery方法:

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;
}

答案 1 :(得分:0)

这对我有用:

ASPX:

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

aspx脚本:

<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);