a9zmgw
Last Updated: February 25, 2016
·
215
· ordepdev
49eba23cc4b611e2bacd22000a9e08df 7

Redirect to previous page

The trick is to store the Request.UrlReferrer in ViewState during the page load.

protected void Page_Load(object sender, EventArgs e)
{    
    if (Page.IsPostBack) return;
    ViewState["PreviousPageUrl"] = Request.UrlReferrer.ToString();
}

protected void btnBack_Click(object sender, EventArgs e)
{
    Page.Response.Redirect(ViewState["PreviousPageUrl"]
        .ToString());
}
Say Thanks
Respond