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

Closing Telerik Window on exception

3 Answers 115 Views
Window
This is a migrated thread and some comments may be shown as answers.
iggy
Top achievements
Rank 1
iggy asked on 01 Apr 2011, 05:58 PM
If an unhandled exception occurs within the page that's loaded in the Telerik Window, how would we close the window and show the unhandled exception in the main page?

I understand that I can inject the javascript to close the window from the server side, but If I inject the script on the OnError handler on the page, the page never completes rendering and the javascript for closing the window never fires.

PS: Currently, we are using the Application_Error in Global.asax.cs to handle unhandled exceptions.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Apr 2011, 07:45 AM
Hello,


How about using RegisterStartupScript() server method to invoke the client method to close window?

More information on invoking the client function will be available in the KB Article.

Closing RadWindow
Executing JavaScript function from server-side code


Regards,
Princy.
0
iggy
Top achievements
Rank 1
answered on 04 Apr 2011, 03:15 PM
That's exactly how I am trying to do it.

The issue is that the page never gets rendered completely (due to the exception) for the script registered using RegisterStartupScript() to be executed.

To duplicate this issue, override OnError

		protected override void OnError(EventArgs e)
{
string s  = "<script language='javascript' type='text/javascript'>Sys.Application.add_load(CloseWin);</script>";
Page.ClientScript.RegisterStartupScript(typeof(Page), "Close", s);
}

and simulate an exception by doing a throw new ApplicationException() in Page_Load method

CloseWin is a JS function that does a:
GetRadWindow().close();
0
Marin Bratanov
Telerik team
answered on 07 Apr 2011, 04:07 PM

Hi Iggy,

This is a general ASP.NET knowledge related to executing a script from the server-side.

We generally do not support custom solutions, but as an exception we have created a sample page that illustrates the approach. You can find it attached. 

Note that this is highly dependant on the postbacks and the same-domain JavaScript policy.


Greetings,
Marin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Window
Asked by
iggy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
iggy
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or