Going back to calling page

Discussion in 'ASP .Net' started by BillGatesFan, Jan 3, 2005.

  1. BillGatesFan

    BillGatesFan Guest

    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?
    BillGatesFan, Jan 3, 2005
    #1
    1. Advertising

  2. BillGatesFan

    Marina Guest

    What's wrong with Response.Redirect?

    "BillGatesFan" <> wrote in message
    news:...
    > 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?
    >
    Marina, Jan 3, 2005
    #2
    1. Advertising

  3. 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

    "BillGatesFan" <> wrote in message
    news:...
    > 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?
    >
    John Timney \(ASP.NET MVP\), Jan 3, 2005
    #3
  4. 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.

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Bill Gates Brother, Jan 3, 2005
    #4
  5. BillGatesFan

    jongalloway Guest

    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
    jongalloway, Jan 4, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nvv via DotNetMonster.com

    avoid a page going back to site after logging out

    nvv via DotNetMonster.com, Jan 27, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    598
    Maheeja Swarna via DotNetMonster.com
    Jan 27, 2005
  2. tshad
    Replies:
    4
    Views:
    601
    tshad
    Feb 1, 2005
  3. =?Utf-8?B?TmFk?=
    Replies:
    6
    Views:
    1,029
    =?Utf-8?B?TmFk?=
    Jun 30, 2005
  4. Steve Murphy
    Replies:
    2
    Views:
    753
    =?Utf-8?B?Sm9l?=
    Jan 15, 2006
  5. =?Utf-8?B?bWF2cmlja18xMDE=?=

    Going back to the same location on page after postback or reload.

    =?Utf-8?B?bWF2cmlja18xMDE=?=, Aug 8, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    1,452
    =?Utf-8?B?bWF2cmlja18xMDE=?=
    Aug 9, 2007
Loading...

Share This Page