Getting the Posted Error Value

7 posts, 1 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 05 May 2010 Link to this post

    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?
  2. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 10 May 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 10 May 2010 Link to this post

    Thanks :)

    This isn't anywhere in the docs though

    Can someone quickly update it with all the functions we can use?
  5. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 10 May 2010 Link to this post

    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.
  6. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 10 May 2010 Link to this post

    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
  7. Igor
    Igor avatar
    1 posts
    Member since:
    Aug 2010

    Posted 18 Aug 2010 Link to this post

    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.
  8. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 23 Aug 2010 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017