Skip to main content
Tab

ASPxWebControl.RedirectOnCallback(String) Method

Redirects a client to a new URL while processing a callback.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

public static void RedirectOnCallback(
    string url
)

Parameters

Name Type Description
url String

A string value specifying the new target location.

Remarks

While a callback is being processed on the server, the RedirectOnCallback method enables you to redirect the application to another web resource.

Example

This example demonstrates how to use the RedirectOnCallback(String) method to redirect a user on an AJAX request, for example, ASPxCallbackPanel control callback. With this method, you can implement user login with asynchronous behavior (Login Control will reload the page even if the validation fails or redirect the user on successful validation, but in this example, the login process is done asynchronously).

View Example

<head runat="server">
    <title>How to redirect user on callback</title>
    <script>
        function ProcessLoginCallback() {
            CallbackPanel.PerformCallback();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <dx:ASPxCallbackPanel ID="CallbackPanel" ClientInstanceName="CallbackPanel" runat="server" Width="200px" OnCallback="CallbackPanel_Callback">
            <PanelCollection>
                <dx:PanelContent>
                    <dx:ASPxValidationSummary ID="ValidationSummary" runat="server"></dx:ASPxValidationSummary>

                    <dx:ASPxLabel ID="LoginLabel" runat="server" Text="Email:"></dx:ASPxLabel>
                    <dx:ASPxTextBox ID="LoginTextBox" runat="server" Width="170px">
                        <ValidationSettings>
                            <RequiredField IsRequired="true" ErrorText="Enter Email" />
                            <RegularExpression 
                                ValidationExpression="^[-a-z0-9!#$%&'*+/=?^_`{|}~]+(?:\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*@(?:[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?\.)*(?:aero|arpa|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel|[a-z][a-z])$" 
                                ErrorText="Bad email address" />
                        </ValidationSettings>
                    </dx:ASPxTextBox>
                    <dx:ASPxLabel ID="PasswordLabel" runat="server" Text="Password:"></dx:ASPxLabel>
                    <dx:ASPxTextBox ID="PasswordTextBox" runat="server" Password="true" Width="170px">
                        <ValidationSettings>
                            <RequiredField IsRequired="true" ErrorText="Password is Required" />
                        </ValidationSettings>
                    </dx:ASPxTextBox>
                    <br />
                    <dx:ASPxButton ID="Button" runat="server" Text="Login" AutoPostBack="false">
                        <ClientSideEvents Click="ProcessLoginCallback" />
                    </dx:ASPxButton>
                </dx:PanelContent>
            </PanelCollection>
        </dx:ASPxCallbackPanel>
    </form>
</body>
private const string loginUrl = "~/Login.aspx";

protected void CallbackPanel_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e) {
    if(ASPxEdit.ValidateEditorsInContainer(sender as ASPxCallbackPanel)) {
        ASPxWebControl.RedirectOnCallback(VirtualPathUtility.ToAbsolute(loginUrl));
    }
}
See Also