Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > XmlHttpPanel > Getting the Posted Error Value

Answered Getting the Posted Error Value

Feed from this thread
  • Posted on May 5, 2010 (permalink)

    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?

    Reply

  • Answer Pero Pero admin's avatar

    Posted on May 10, 2010 (permalink)

    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.

    Reply

  • Posted on May 10, 2010 (permalink)

    Thanks :)

    This isn't anywhere in the docs though

    Can someone quickly update it with all the functions we can use?

    Reply

  • Pero Pero admin's avatar

    Posted on May 10, 2010 (permalink)

    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.
    Attached files

    Reply

  • Posted on May 10, 2010 (permalink)

    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

    Reply

  • Igor avatar

    Posted on Aug 18, 2010 (permalink)

    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.

    Reply

  • Pero Pero admin's avatar

    Posted on Aug 23, 2010 (permalink)

    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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > XmlHttpPanel > Getting the Posted Error Value