Need C# function for javascript function Browser.History.Back

  • Thread starter Thread starter Lubo¹ ©lapák
  • Start date Start date
L

Lubo¹ ©lapák

Hi,
I need (in one function in aspx page) return the WWW browser back to
previous page.
How can I do it?

Thanks
 
I wouldn't have thought you could do that from code as the Back
functionality uses the browsers history. I suppose you could set your ASPX
page to run a javascript function once its loaded that calls
Browser.History.Back????

MattC
 
Hi LuboOne,
For a serverside "Back"-function use:
Response.Redirect(Request.Referrer.AbsoluteUri);

This only works if it isn't a postback. If your page does postbacks use:
if(!IsPostBack)
{
ViewState.Add("ref",Request.UrlReferrer.AbsoluteUri);
}

....in page load, and the do:
Response.Redirect((string)ViewState["ref"]);

....when you want to go back.

/Hugo
 
Back
Top