Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to control which page to return

Status
Not open for further replies.

chrislx

Programmer
Oct 17, 2003
32
0
0
US
I have 2 pages aa.aspx and bb.aspx and both link to the 3rd page cc.aspx. There is a return button on the cc.aspx. How to control which page to be returned after the Return button is clicked

I have defined invisible lables lblCalledFrom.Text = 1 on page aa.aspx and calledFrom.Text = 2 on bb.aspx and defined variables protected string calledFrom in aa..aspx.cs and bb.aspx.cs which are assigned with lblCalledFrom.Text. The third page cc.aspx cannot get the value since they are the variables at page level.
I tried to create a variable of public string type in global.aspx and assign it with the value of calledFrom in aa.aspx.cs and bb.aspx.cs, and thought that cc.aspx would notice each time the value of calledFrom is changed The problem is I got compiling error and the global variable cannot be accepted either page. Is there any way to define a global variable, all pages will know once the value is changed?
 
YOu can find what page called CC.aspx with, Request.UrlReferrer

Then you can use that for the click of the button to redirect
 
As Jim said you can use the referrer however some browsers may not pass this information on.

You could also use a session variable, a cookie or a querystring (but again there may be cases where it is not 100% accurate).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks for the tip. It works. There is another page dd.aspx which links to cc.aspx. Is there any way to know which way it comes down since there are 2 paths:
aa -> cc -> dd
bb -> cc -> dd
The data shown on aa and bb pages are from 2 different db tables.

The only data I can seen from dd page is the ID from cc page.
I used the following statement in the btnReturn_Click:
Response.Redirect("cc.aspx?id=" + rd.AutoCtlNo.ToString());
then, I got error message "Object reference not set to an instance of an object." and no data is shown on the cc page after returning.

I guess that I should call DS method to access data from either tables. But do not know which table I should call, or in another word, which path it came from.

Thanks in advance.
 
Store the list of Referrers in a session variable and check the order on dd.aspx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top