Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Disable back button not working - tried several different options - no luck!

$
0
0

I  tried the following to disable back button in FF or IE with no luck can still use browser back button.

Any ideas why this is not working?

   Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
        ' Disable back button - does not work
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
        Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1))
        Response.Cache.SetNoStore()
    End Sub

    Protected Overloads Overrides Sub OnPreRender(ByVal e As EventArgs)
        ' Disable back button - does not work
        MyBase.OnPreRender(e)
        Dim strDisAbleBackButton As String
        strDisAbleBackButton = "<script language=""javascript" > """ & vbLf" + "window.history.forward(1);" & vbLf + vbLf & "</script>"
        ClientScript.RegisterClientScriptBlock(Me.Page.[GetType](), "clientScript", strDisAbleBackButton)
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        ' Disable back button - does not work
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
        Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1))
        Response.Cache.SetNoStore()
     End Sub


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>