RadAlert not in radwindowmanager window array

2 posts, 0 answers
  1. Nick
    Nick avatar
    1 posts
    Member since:
    Jan 2014

    Posted 15 Jan 2014 Link to this post


    I have a radwindowmanager in a master page, with 2 radwindows defined, and an alert template, like so:

    <telerik:RadWindowManager ID="myId" runat="server" ReloadOnShow="true"<br>
            OnClientShow="Hideloading" DestroyOnClose="true"><br>
                <div class="rwDialogPopup radalert"><br>
                    <div class="rwDialogText"><br>
                        <div class="space"><br>
                        <br /><br>
                        <a onclick="$find('{0}').close();FocusLastFocusedControl();" onkeypress="return GetChar(event,'{0}');"<br>
                            class="rwPopupButton" href="javascript:void(0);"><span class="rwOuterSpan"><span<br>
                                class="rwInnerSpan">##LOC[OK]##</span> </span></a><br>
                        <div class="clear"><br>
                <telerik:RadWindow ID="id1" AutoSize="true" Modal="true" Title="title1"<br>
                    runat="server"  KeepInScreenBounds="true" VisibleStatusbar="false"<br>
                    RegisterWithScriptManager="true" Behaviors="Close, Move, Resize" Height="450px"<br>
                    OnClientBeforeShow="ClientShow" AutoSizeBehaviors="Height"><br>
                        <%--  ... --%><br>
                <telerik:RadWindow ID="id2" AutoSize="true" Modal="true" ReloadOnShow="True"<br>
                     KeepInScreenBounds="true" VisibleStatusbar="false"<br>
                    RegisterWithScriptManager="true" Behaviors="Move, Resize"<br>
                    DestroyOnClose="true" runat="server" OnClientClose="CloseAddNoteWindow" Title="title2"><br>

    Now, from a client page I try to catch any error and show a message to the user via radalert by calling it from code-behind, like so:

    RadWindowManager1.RadAlert(ex.Message, 450, 210,

    What I'm trying to do is check if multiple radalerts are open, close them and show only one radalert with a generic message. I try to do this in the master page like this

                function loadHandle() {
                    var wManager = GetRadWindowManager();
                    var windows = wManager.get_windows();
                    var wCount = windows.length;
                    if (wCount > 3)
                        //close all pop-ups and display a generic message pop-up about multiple errors
                        radalert('Multiple errors', null, null, 'Multiple errors');

    The problem is that 'wManager.get_windows();' only contains the 2 RadWindows I have defined, and not the radalerts. Why is that? Is there some other way I can achieve what I want?
  2. Marin Bratanov
    Marin Bratanov avatar
    3907 posts

    Posted 16 Jan 2014 Link to this post

    Hi Nick,

    RadAlerts, RadConfirms and RadPrompts are templated popups that are not added in the windows collection of the manager because they are disposed as soon as they are closed.

    Perhaps handling multiple errors can be done by concatenating messages on the server, or counting error occurrences on the server to determine the final message to be shown.

    Another approach would be a JavaScript counter that can be increased with each alert call so you could check this counter for many alerts, e.g.:
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    <asp:Button ID="Button1" Text="postback" runat="server" />
    code-behind mockup
    protected void Page_Load(object sender, EventArgs e)
        RadWindowManager1.RadAlert("one", null, null, "", "");
        RadWindowManager1.RadAlert("two", null, null, "", "");
        RadWindowManager1.RadAlert("three", null, null, "", "");
    protected void IncreaseAlertCount()
        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),Guid.NewGuid().ToString(), "alertCounter++;", true);

    script on the page:
    var alertCounter = 0;
    function loadHandle()
        var wManager = GetRadWindowManager();
        setTimeout(function ()
            //check predefined dialogs count
            if (alertCounter > 2)
                //close the mall and show common alert
                wManager.radalert("too many errors");
                //reset counter
                alertCounter = 0;
        }, 0);
    function closePredefinedDialogs()
        //get all popup elements
        $telerik.$(".RadWindow").each(function (index, elem)
            //build the Component name from the popup element ID
            var ctrl = $find(elem.getAttribute("id").substring(17));
            //check if it is a predefined dialog (RadAlert, RadConfirm, RadPrompt) and close it as if the [x] button is clicked
            if (ctrl && ctrl._isPredefined && ctrl.isVisible())

    Marin Bratanov
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top