Back to Devexpress

ASPxWebControl.GetCallbackErrorMessage() Method

aspnet-devexpress-dot-web-dot-aspxwebcontrol-c769c4f0.md

latest6.3 KB
Original Source

ASPxWebControl.GetCallbackErrorMessage() Method

Obtains the error info while processing the redirection page.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public static string GetCallbackErrorMessage()
vb
Public Shared Function GetCallbackErrorMessage As String

Returns

TypeDescription
String

A string value representing the error info.

|

Remarks

When a server error occurs during a callback processing, and the request is redirected to a specific page (which is specified via the callbackErrorRedirectUrl option within a specific <devExpress> section of the Web.Config file), you can use the static GetCallbackErrorMessage method to obtain the error info within the redirection page.

See Response Redirection on Callback Exceptions to learn more.

Example

In this example, the error message is displayed within the redirected page ( Error.aspx ) after an exception occurs on a callback within the Default.aspx page.

The redirection page is specified within the devExpresserrors section of the web.config file via the callbackErrorRedirectUrl key (see Redirection on a Callback Error). The error message is obtained by using the static ASPxWebControl.GetCallbackErrorMessage method.

Note

To provide the message redirection between pages, the ASPxHttpHandlerModule should be registered within the web.config file.

aspx
<dx:ASPxButton id="ASPxButton1" runat="server" AutoPostBack="False" text="Perform Callback">
    <ClientSideEvents Click="function(s, e) { callback1.PerformCallback(); }"></ClientSideEvents>
</dx:ASPxButton>
<dx:ASPxCallback ID="ASPxCallback1" runat="server" ClientInstanceName="callback1"></dx:ASPxCallback>
aspx
<head runat="server">
    <title>Error</title>
</head>
<body>
    <form id="form1" runat="server">
    </form>
</body>
</html>
csharp
public partial class _Default : Page {
    protected void Page_Load(object sender, EventArgs e) {
        if(IsCallback) {
            NotImplementedException innerException = new NotImplementedException("NoReport");
            throw new NotImplementedException("This message has been generated for a GetCallbackErrorMessage() method demonstration.", innerException);
        }
    }
}
vb
Partial Public Class _Default
    Inherits Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        If IsCallback Then
            Dim innerException As New NotImplementedException("NoReport")
            Throw New NotImplementedException("This message has been generated for a GetCallbackErrorMessage() method demonstration.", innerException)
        End If
    End Sub
End Class
csharp
using System;
using System.Web.UI;
using DevExpress.Web;

public partial class Error : Page {
    protected void Page_Load(object sender, EventArgs e) {
        string errorMessage = ASPxWebControl.GetCallbackErrorMessage();
        Response.Output.Write(errorMessage);
    }
}
vb
Imports System
Imports System.Web.UI
Imports DevExpress.Web

Partial Public Class [Error]
    Inherits Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim errorMessage As String = ASPxWebControl.GetCallbackErrorMessage()
        Response.Output.Write(errorMessage)
    End Sub
End Class

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetCallbackErrorMessage() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

asp-net-web-forms-grid-upload-and-display-excel-file/CS/Solution/Error.aspx.cs#L7

csharp
protected void Page_Load(object sender, EventArgs e) {
    string errorMessage = ASPxWebControl.GetCallbackErrorMessage();
    Response.Output.Write(errorMessage);

asp-net-web-forms-grid-upload-and-display-excel-file/VB/Solution/Error.aspx.vb#L13

vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim errorMessage As String = ASPxWebControl.GetCallbackErrorMessage()
    Response.Output.Write(errorMessage)

See Also

Redirect a Response on a Callback Exception

Callbacks

ASPxWebControl Class

ASPxWebControl Members

DevExpress.Web Namespace