.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

how to go back to previous page in asp .NET

Posted By: Shanthini     Posted Date: June 18, 2009    Points:2   Category :ASP.Net
In the webpage, i need a back button which will take us to previous page viewed by the user.
I have tried out the following option,

/****** when i tried this is loading the current page again
String Prev_page = Request.ServerVariables["HTTP_REFERER"];
Response.Redirect(Prev_page);


/******This is also loading the cuurent page again

string prevPage = Request.UrlReferrer.ToString();
Response.Redirect(prevPage);

/******This is throwing exception.
javascript:history(-1)

Please provide me the idea for navigating to prevoius page by clicking the Button

I need C# asp .Net code.

Responses
Author: Amit Mehra             
Posted Date: June 18, 2009     Points: 5   

hi,
you have to use javascript and the syntax is


history.go(-1)

or

history.back();


Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Shanthini             
Posted Date: June 18, 2009     Points: 5   

Amit,

Its working fine. Previously, it doesn't work out bcos i have included asp:button and tried history.go(-1)..

After changing asp:button as HTML button, its working fine... Thank u for ur reply :-)



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend