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

Getting the Posted Error Value

6 Answers 106 Views
XmlHttpPanel
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 05 May 2010, 03:22 PM
I want to provide a "Refresh" link for the user if the Callback fails...is there a way to get the posted Error Value in the Error Callback Method somehow?

6 Answers, 1 is accepted

Sort by
0
Accepted
Pero
Telerik team
answered on 10 May 2010, 12:09 PM
Hello Steve,

The error message can be retrieved using the get_errorMessage() client-side method of the event arguments. The following code alerts the error message received from the XmlHttpPanel:

.aspx
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
    <title></title>
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
 
        <script type="text/javascript">
            function SetValue()
            {
                var panel = $find("<%=XmlPanel1.ClientID %>");
                panel.set_value("Some_Value");
            }
 
            function OnClientResponseError(sender, args)
            {
                alert("XmlHttpPanel Value: " + sender.get_value());
 
                //Comment this line and the default error message will be alerted
                args.set_cancelErrorAlert(true);
 
                alert("XmlHttpPanel Error: " + args.get_errorMessage());
            }
        </script>
 
    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
        </Scripts>
    </asp:ScriptManager>
    <asp:Button ID="Button2" runat="server" Text="Postback" />
    <input value="Set Value (callback)" onclick="SetValue(); return false;" type="button" />
    <div>
        <telerik:RadXmlHttpPanel ID="XmlPanel1" runat="server" OnServiceRequest="XmlPanel1_ServiceRequest"
            EnableClientScriptEvaluation="true" OnClientResponseError="OnClientResponseError">
        </telerik:RadXmlHttpPanel>
    </div>
    </form>
</body>
</html>

.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class XmlPanel_Lifecycle : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
 
    protected void XmlPanel1_ServiceRequest(object sender, Telerik.Web.UI.RadXmlHttpPanelEventArgs e)
    {
        throw (new Exception("CUSTOM EXCEPTION"));
    }
 
}


All the best,
Pero
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.
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 10 May 2010, 01:04 PM
Thanks :)

This isn't anywhere in the docs though

Can someone quickly update it with all the functions we can use?
0
Pero
Telerik team
answered on 10 May 2010, 01:30 PM
Hello Steve,

I'm glad you resolved your problem.

We will update the documentation as soon as we can. Please note that, besides the online documentation, you can use the client-side Intellisense, which in my opinion is more helpful. Here is a help article showing how to use the intellisense: http://www.telerik.com/help/aspnet-ajax/intellisense-vs2010.html.


Sincerely yours,
Pero
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.
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 10 May 2010, 01:33 PM
I've never been able to get intellisense to work with 2010, given up really

That link says you need to drag-drop a control onto the page, but I usually just create manually due to the gimpy design view rendering :)

Also the intellisense doesn't work in ASCX files which is where I do most of the building
0
Igor
Top achievements
Rank 1
answered on 18 Aug 2010, 06:24 PM
Hello,

Suggested solution works fine as long as i have <customErrors mode="Off"...> in web.config. If it's ON, i always receive ''There was an error in the callback." message instead of custom exception text.

Is there a workaround for my scenario to get proper error message?

Thanks.
0
Pero
Telerik team
answered on 23 Aug 2010, 09:26 AM
Hi Igor,

When you have specified <customErrors/> with mode="On" the users will see the generic errors, and the custom errors, as described in the following MSDN article: http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx.

You can't work around to get the custom exception message. The only way is to set the mode to "Off" or "RemoteOnly".

Sincerely yours,
Pero
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
XmlHttpPanel
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Pero
Telerik team
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Igor
Top achievements
Rank 1
Share this question
or