Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to handle back button event of the browser?

How to handle back button event of the browser?

Scheduled Pinned Locked Moved ASP.NET
questiontutorial
9 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    iamdking
    wrote on last edited by
    #1

    Hello friends, I want to handle "Back" buttons event of the browser in my code. I want to restrict the user from pressing back button..How can I do that? Thanks ,

    Amit

    C V 2 Replies Last reply
    0
    • I iamdking

      Hello friends, I want to handle "Back" buttons event of the browser in my code. I want to restrict the user from pressing back button..How can I do that? Thanks ,

      Amit

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You cannot. Don't worry, people ask this all the time. There's no way to handle it, it's not an event, it happens on the client. You can try to hack it, but not successfully. Usually when people ask this, it's because they have not written the code to handle logout properly, is that your issue ?

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      I 1 Reply Last reply
      0
      • C Christian Graus

        You cannot. Don't worry, people ask this all the time. There's no way to handle it, it's not an event, it happens on the client. You can try to hack it, but not successfully. Usually when people ask this, it's because they have not written the code to handle logout properly, is that your issue ?

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        I Offline
        I Offline
        iamdking
        wrote on last edited by
        #3

        Thanks, Here logout is not the issue. I want to give message to user, if he clicks the back button only.. I Saw some bank sites..They closing the sessions if user clicks the back button..! How they do that? Need help..

        Amit

        N 1 Reply Last reply
        0
        • I iamdking

          Thanks, Here logout is not the issue. I want to give message to user, if he clicks the back button only.. I Saw some bank sites..They closing the sessions if user clicks the back button..! How they do that? Need help..

          Amit

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          Javascript. But it's not reliable as JS can be turned off by the user.

          All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

          I 1 Reply Last reply
          0
          • N N a v a n e e t h

            Javascript. But it's not reliable as JS can be turned off by the user.

            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

            I Offline
            I Offline
            iamdking
            wrote on last edited by
            #5

            Any Example? or documents?

            Amit

            W E 2 Replies Last reply
            0
            • I iamdking

              Any Example? or documents?

              Amit

              W Offline
              W Offline
              www Developerof NET
              wrote on last edited by
              #6

              This might help u... http://www.codeproject.com/KB/aspnet/NoCaching.aspx[^]

              When you fail to plan, you are planning to fail.

              I 1 Reply Last reply
              0
              • I iamdking

                Any Example? or documents?

                Amit

                E Offline
                E Offline
                eyeseetee
                wrote on last edited by
                #7

                I would avoid using javascript for a security method. As mentioned before a user can simply turn it off in their browser by-passing your security

                We are not a Code Charity

                1 Reply Last reply
                0
                • I iamdking

                  Hello friends, I want to handle "Back" buttons event of the browser in my code. I want to restrict the user from pressing back button..How can I do that? Thanks ,

                  Amit

                  V Offline
                  V Offline
                  Vasudevan Deepak Kumar
                  wrote on last edited by
                  #8

                  One thing you can do is redirect all links through location.replace() of JavaScript so that there would be no history and hence back button can be voided to some extent. You can also try using the history.forward() trick.

                  Vasudevan Deepak Kumar Personal Homepage
                  Tech Gossips
                  All the world's a stage, And all the men and women merely players. They have their exits and their entrances; And one man in his time plays many parts... --William Shakespeare

                  1 Reply Last reply
                  0
                  • W www Developerof NET

                    This might help u... http://www.codeproject.com/KB/aspnet/NoCaching.aspx[^]

                    When you fail to plan, you are planning to fail.

                    I Offline
                    I Offline
                    iamdking
                    wrote on last edited by
                    #9

                    Thanks...Very goood article...

                    Amit

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups