Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

FREE 12 month online training for ASP.NET & MS Expression Studio and a Free copy of MS Expression Web with Windows Server Purchase
Navigating an ASP.Net Page

Author: DevASP
Download Source Code : 422_GoBack.zip

This article is about how you can go back or forward in your browser. Suppose you want to give the user of your site functionality just like the Back and Forward Buttons in the IE.

  • Steps you will do. 
  • Start visual studio and create a new web application. 
  • Drop a label control on your first web form and set its following properties.

 

Text  = “Its easy to track the previous page”

 

  •  Now drop a button control on the form and set its following properties as below.

 

Name = “btNext”

Text = “Go To Next Page”

 

  • Declare a global variable as below.

 

protected static string previouspage;

 

Now open your code window and write the following line of code in the click event of page load event.

 

previouspage = Request.ServerVariables["HTTP_REFERER"];

        

 

In the click event of the button write the following line of code. In the line of code a parameter is send with the query string which is the URL of the previous page.

 

Response.Redirect("Form2.aspx?previouspage=" + previouspage);

 

 

Now add a new web form into your project. 

Drop a label control on the form and set its following properties. 

Text = “Click the button below to go back to previous page”

Now drop a button control on the form and set its following properties as below:

 

Name = “btPrevious”

Text = “Go Back”

 

Open the code window of second web form and write following code in the click event of the button to go back to the previous page. Actually what does it do? It gets the a URL which we send in query string from the first web form and redirect the user to that URL.

 

Response.Redirect(Request.QueryString["previouspage"]);

 

 

Now you can do the functionality of the previous button yourself as we do that of previous button.

Article Comments
Index.aspx

Response.Redirect("Ad.aspx?UserName=" & txtUserName.Text)

ad.aspx

UserId.Text = Request.QueryString("UserName")

previouspage = Request.ServerVariables("HTTP_REFERER")



but
Request.ServerVariables("HTTP_REFERER")
not returning Index.aspx

why this is so.

please help

regards,
Nagraj

Posted on 8/10/2006 6:30:54 AM by nagraj

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Creating and hiding OverLoaded Delete Functions in VB.Net

Disclaimer - Privacy
© 2002-2014 DevASP.net