Reputation: 1591
I am trying to add a back button on a popup. But I have having issues because I am getting a 403 error. I have also tried Request.UrlReferrer.ToString(). Simply right clicking and selected back works and the client does not want the tool bar with the stnard IE back button on the pop up. Any suggestions?
Protected prevPage As String = String.Empty
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
prevPage = Request.ServerVariables("HTTP_Referer")
End If
End Sub
Protected Sub Back_Click(ByVal sender As Object, ByVal e As EventArgs)
Response.Redirect(prevPage)
End Sub
Upvotes: 0
Views: 1045
Reputation: 37533
Use javascript instead of a postback.
<asp:HyperLink ID="lnk" runat="server" NavigateUrl="#" onClientClick="history.go(-1);" Text="Go Back" />
This would an asp.net control that could be modified in the code behind, but this could just as easily be a standard <a>
element.
Edit:
If you have multiple postbacks happening on the page, the history may not work for them properly. You may have to put in a tracker and change the integer depending on how many postbacks have occurred. Also, if you have multiple postbacks to a single page, then navigate away from that page, going "back" may result in an improper post to the returned page.
Upvotes: 1