This is a migrated thread and some comments may be shown as answers.

detect rad alert is closed

4 Answers 58 Views
Window
This is a migrated thread and some comments may be shown as answers.
Mohammed
Top achievements
Rank 2
Mohammed asked on 06 Sep 2012, 02:56 PM
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,

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 07 Sep 2012, 04:56 AM
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.
0
Mohammed
Top achievements
Rank 2
answered on 07 Sep 2012, 12:16 PM
Thanks Princy,
using flag is good workaround, i thought there is a method like IsClosed() for rad window.
thanks again for helping.
regards,
0
rdmptn
Top achievements
Rank 1
answered on 07 Sep 2012, 12:24 PM
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.
0
Mohammed
Top achievements
Rank 2
answered on 07 Sep 2012, 01:16 PM
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.

Tags
Window
Asked by
Mohammed
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 1
Mohammed
Top achievements
Rank 2
rdmptn
Top achievements
Rank 1
Share this question
or