Going back to calling page

B

BillGatesFan

Let's say I'm in a.aspx and I do a response.redirect to b.aspx. Then I
show and hide a couple of panels in b.aspx and now I want to click a
button to take me back to a.aspx. how do I do that without doing
response.redirect?
 
J

John Timney \(ASP.NET MVP\)

You can use the meta tags or javascript to move the page client side, or
server.transfer server side...I would redirect to the referrer.
--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
B

Bill Gates Brother

The problem with it was I needed to go back to the correct page. My
example was kind of wrong. I'm on c.aspx, a.aspx and b.aspx could get to
c.aspx. How do I get back to the correct one that got me to c.aspx? If I
knew which one, then I could use response.redirect.
 
J

jongalloway

One method is to add the referer to Viewstate the first time the page
is loaded (Postback == false). This example uses a button, but once you
have the referer you can do whatever you want with it.

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
BackPath = Request.UrlReferrer.ToString();
ViewState.Add("BackPath", BackPath);
}
else
{
BackPath = ViewState["BackPath"].ToString();
}
}

private void btnBack_Click(object sender, System.EventArgs e)
{
Response.Redirect(BackPath, false);
}

There are some other, more sophisticated approaches. Juval Lowy has
written a server control that handles this functionality:
http://www.ftponline.com/vsm/2003_07/magazine/columns/qa/
- Jon
http://weblogs.asp.net/jgalloway
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top