asp.netajaxupdatepanelresponse.redirectupdateprogress

Response.Redirect not working when using UpdateProgress


I use an UpdatePanel and UpdateProgress.

Both Response.Redirect and JavaScript redirect window not working with them.

This code is working:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DynamicLayout="true"
        AssociatedUpdatePanelID="UpdatePanel1">
    <ProgressTemplate>
        <asp:Image ID="ImageWait" runat="server" ImageUrl="../images/wait.gif" />
    </ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Button ID="ButtonSave" runat="server" Text="Save"
        OnClick="ButtonSave_Click" ValidationGroup="Valid1" />
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="ButtonSave"
            EventName="Click" />
    </Triggers>
</asp:UpdatePanel>

Not working :

protected void ButtonSave_Click(object sender, EventArgs e)
{
    // Saved here

    Response.Redirect("../Main/Success.aspx");
}

Not working, too :

protected void ButtonSave_Click(object sender, EventArgs e)
{
    // Saved here

    Page.ClientScript.RegisterStartupScript(this.GetType(), "redirect",
        "location.href = '../Main/Success.aspx'", true);
}

How can I fix this ?


Solution

  • You can use the ScriptManager

    protected void redirector_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterClientScriptBlock(this, GetType(), "redirect",
            "location.href = 'ListViewDemo.aspx';", true);
    }