|
Rank: Advanced Member Groups: Member
Joined: 8/24/2007 Posts: 130
|
Hi, I have an exception handling strategy that overrides the Page.OnError method to perform exception handling. Now that I have started to use CallbackPanel, I obviously need to handle exceptions in a special way (i.e. using the callback panel Redirect method onto an error page, rather than Response.Redirect). Is there an easy way to find out in Page.OnError whether we are handling a standard postback, or whether it is an AJAX callback? And if it is an AJAX callback, which panel to use for the Redirect?
Many Thanks Phil Wynn
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, That's a very good question. You can use this property to determine whether you are inside a Callback but it probably won't help you too much: http://www.essentialobjects.com/ViewDoc.aspx?t=EO.Web.Callback.IsCallback.htmlThe reason is when an exception occurs, the page flow goes out of the normal cycle. CallbackPanel is a control, just like any other control, it relies on a normal page cycle to function. So when the page cycle is interrupted, there isn't much CallbackPanel can do --- various events of the CallbackPanel may not get called, or the CallbackPanel itself may have not been correctly initialized at all. Basically, you can not rely on any page controls in Page.OnError. In order to correctly handle the error without relying on the Callback, use the following code to do a redirect: //Form variable eo_cb_id contains the ID of the triggering CallbackPanel if (Request.Form["eo_cb_id"] != null) { //CallbackPanel client side code recognizes this format Response.Clear(); Response.ContentType = "text/xml"; Response.StatusCode = 200; Response.Write("<Data><Redirect>http://www.your_domain.com/your_error_page.aspx</Redirect></Data>"); Response.End(); } That should get you going. Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 8/24/2007 Posts: 130
|
Hi,
I have used you example code to provide exception handling in the Page.OnError method, however, I have encountered a problem. The code works fine when the postback has been caused by a button within the callback panel that is specified callback panel trigger, but when the postback is caused by a button within the callback panel that is not set as a trigger, I do not get a ridirect, but get the xml rendered on the browser as follows....
<Data> <Redirect>Redirect.aspx</Redirect> </Data>
In this case, I do not want to specify the button as a trigger.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi Phil, You might want to check this:
Code: C#
string s = Request.Form["eo_cb_id"];
if ((s != null) && (s != string.Empty))
{
//redirect.....
}
Note this checks it against both null and empty. Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 8/24/2007 Posts: 130
|
Thanks, that seems to have done the trick
|
|
Rank: Advanced Member Groups: Member
Joined: 8/24/2007 Posts: 130
|
Hi,
This solution no longer works for IE11. I am getting a script error. Could you please advise me ASAP as to how I can resolve this, as this is affecting our live site. I am currently using EO 2013.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi Phil,
We have posted a new build that should address this issue. Please see your private message for the download location.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 8/24/2007 Posts: 130
|
That has fixed it.
Thank you for the prompt resolution.
|
|