You can use a flag to determine whether you should cancel the event:
and inject a script
that will close the RadWindow from the code-behind (and reduce the flag to false, of course).
I am also attaching a simple page that shows this in action to the thread. It uses a session variable to simulate your logic and odd clicks close the RadWindow, even - do not: http://screencast.com/t/GY0hRcMNfH
. I am also using the RadAjaxManager for ease of demonstration, yet this approach should also work with your AJAX calls.
the Telerik team
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 their blog feed