Welcome Guest Search | Active Topics | Sign In | Register

Callback panel exception handling Options
Mike Wynn
Posted: Wednesday, September 19, 2007 3:21:05 AM
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
eo_support
Posted: Wednesday, September 19, 2007 8:03:44 AM
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.html

The 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
Mike Wynn
Posted: Monday, October 29, 2007 7:28:04 AM
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.
eo_support
Posted: Monday, October 29, 2007 8:28:50 AM
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
Mike Wynn
Posted: Monday, October 29, 2007 8:50:31 AM
Rank: Advanced Member
Groups: Member

Joined: 8/24/2007
Posts: 130
Thanks, that seems to have done the trick
Mike Wynn
Posted: Friday, December 27, 2013 6:52:16 AM
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.
eo_support
Posted: Friday, December 27, 2013 5:04:18 PM
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!
Mike Wynn
Posted: Friday, January 3, 2014 5:08:42 AM
Rank: Advanced Member
Groups: Member

Joined: 8/24/2007
Posts: 130
That has fixed it.

Thank you for the prompt resolution.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.