detect rad alert is closed

5 posts, 0 answers
  1. Mohammed
    Mohammed avatar
    87 posts
    Member since:
    Aug 2011

    Posted 06 Sep 2012 Link to this post

    Dear Team,

    I've a custom validator that showing a rad alert using window manager.
    the problem is the custom validator is fired twice some times so it make two rad alert.
    how can i detect if the rad window is already opened or closed ? 

    when i use rad window i can do that by using this method isClosed()

    regards,
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Sep 2012 Link to this post

    Hi Mohammed,

    One suggestion is that you can set a variable in the OnClientClose function of RadWindowManager and show RadAlert based on that variable. Following is the sample code.

    ASPX:
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" OnClientClose="OnClientClose"   >
    </telerik:RadWindowManager>
    <button style="width: 150px;" onclick="alertCallBackFn(); return false;">radalert</button>

    JS:
    <script type="text/javascript">
        var closed = null;
        function alertCallBackFn() {
            if (closed != true) {
                radalert("RadAlert", null, null, "radalert");
            }
       }
       function OnClientClose(sender, args) {
           closed = true;
       }
    </script>

    Hope this helps.

    Regards,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mohammed
    Mohammed avatar
    87 posts
    Member since:
    Aug 2011

    Posted 07 Sep 2012 Link to this post

    Thanks Princy,
    using flag is good workaround, i thought there is a method like IsClosed() for rad window.
    thanks again for helping.
    regards,
  5. rdmptn
    rdmptn avatar
    72 posts
    Member since:
    Aug 2011

    Posted 07 Sep 2012 Link to this post

    There actually is an isClosed() method of the RadWindow: http://www.telerik.com/help/aspnet-ajax/window-programming-radwindow-methods.html. Your problem is that it is related to a specific RadWindow instance and not if generally a RadWindow has already been closed on the page. Working with the RadAlerts is done in their callbacks functions: http://www.telerik.com/help/aspnet-ajax/window-dialogs-alert.html. They are also created dynamically, so you wouldn't know how many are shown unless you raise a flag. You can do that when opening the alert then flip the flag in its callback function, much like Princy suggested.
  6. Mohammed
    Mohammed avatar
    87 posts
    Member since:
    Aug 2011

    Posted 07 Sep 2012 Link to this post

    thanks rdmptn,

    the provided link really helped me because in my case i need to prevent the custom validator to fire twice.
    in princy case the flag will change its status if we close the window but if it is still display then we would get more than one window displayed.

    but the other link can give me a reference to the displayed window as mentioned below
    var oAlert = radalert(text, oWidth, oHeight, oTitle, callbackFn, imgUrl);

    This method also returns a reference to the RadAlert object (which is essentially a RadWindow), so you can use the RadWindow's client-side API on it to further change it (titlebar icon, behaviors, etc.)

    so from oAlert i can use IsClosed() function to check if the window still display or not

    thanks very much guys for helping, i really appreciate it.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017