go back from server side

  • Thread starter Thread starter Bratislav Jevtic
  • Start date Start date
B

Bratislav Jevtic

hi,

ASP.NET, framework 1.0, patch 2, Windows 2000 server

is this possible: from server side to say "go back" to browser?
-------------------
scenario:

I've got some page with a list. When one clicks some button goes to "detail"
page - for to add/update data. That form may have number of postbacks. On
submit button (or any other, like cancel) server must redirect or transfer
to previous page (list). But, not hardcoded path are allowed. This is
important because this detail form may be called from more then one point in
application, so it cannot know who is caller.

ok, you may say "use session object" and some coding but, I'm interested is
it possible without using Session and coding.
----------

Moreover, is there some Session history - list of urls accessed by user?

thanks in advance,
bj
 
BJ,

The information that you are looking for is specific to the client, and
because HTTP is a connectionless protocol, you will need to use client-side
code to do this. History.Back from the client will take you one page back
in the history.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
 
Request.ServerVariables("HTTP_REFERER") returns the URL of the last page
that this page was navigated to from. However, be aware that you need to
capture this string prior to any PostBacks, as after PostBack, it will be
the url of the current page. One method for persisting this across PostBacks
would be to put something like this in your Page_Load Sub:

If Not IsPostBack Then
ViewState("Referer") = Request.ServerVariables("HTTP_REFERER")
End If

You can then pull it from ViewState on any successive PostBack.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
Kevin Spencer said:
Request.ServerVariables("HTTP_REFERER") returns the URL of the last page
that this page was navigated to from. However, be aware that you need to
capture this string prior to any PostBacks, as after PostBack, it will be
the url of the current page. One method for persisting this across PostBacks
would be to put something like this in your Page_Load Sub:

If Not IsPostBack Then
ViewState("Referer") = Request.ServerVariables("HTTP_REFERER")
End If

You can then pull it from ViewState on any successive PostBack.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

I think you can use a HTML Button control (not asp:button) on your
aspx page, and put javascript code to handle the retun to previous
page. The code will be like as follows. (when I created asp:button on
a aspx page, it was not working for me, so I had to change it to html
button, then it worked fine).


<INPUT id="htmlBtnBack" onclick="TakeMeBack()" type="button"
value="Back to Previous Page"></P>

<HTML>
<HEAD>
<script language="JavaScript">
function TakeMeBack() {
window.history.go(-1);
}
</script>
</HEAD>
</HTML>

This is just an example. Thanks.

J Sahoo
 
That's the way I would do it so that you don't place the load on your
server to handle the request.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
 
Back
Top