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. disabling back button,

disabling back button,

Scheduled Pinned Locked Moved ASP.NET
csharphelpquestion
6 Posts 4 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.
  • H Offline
    H Offline
    Hema Bairavan
    wrote on last edited by
    #1

    Hi i am doing an web application , in which i have to disable the back button using the C# code. can you please help me?? else, can any one tell some coding in the asp side so that i can paste directly in the page??

    D F S 3 Replies Last reply
    0
    • H Hema Bairavan

      Hi i am doing an web application , in which i have to disable the back button using the C# code. can you please help me?? else, can any one tell some coding in the asp side so that i can paste directly in the page??

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      You may have to solve this with some Javascript, so that you can trap the user when they press the Backspace Key on the keyboard.

      function fOnKeypress() {

      try {

      var charCode = window.event.keyCode;
      
      if (charCode == 13) {
        window.event.keyCode= 9;
      }
      

      }
      catch (er) {
      //alert('fOnKeypress ' + er);
      }
      }

      You will need to load this in the BODY OnLoad event. I'm usign something like this:

      var objForm= document.getElementById("aspnetForm"); // There should be a better way to get the name of the form instead of hard-coding it like this.
      objForm.onkeydown=fOnKeypress;

      1 Reply Last reply
      0
      • H Hema Bairavan

        Hi i am doing an web application , in which i have to disable the back button using the C# code. can you please help me?? else, can any one tell some coding in the asp side so that i can paste directly in the page??

        F Offline
        F Offline
        Frauke
        wrote on last edited by
        #3

        Very easy to enable or disable a button through C#. If your page has the following button:

        <asp:Button ID="Button1" runat="server" Text="Click me" onclick="Button1_Click" />

        Then you can enable/disable it in your code-behind file through setting its 'enabled' property: Button1.Enabled = false; or Button1.Enabled = true Hope this helps! :) Frauke

        Frauke Nonnenmacher Creative Cats

        1 Reply Last reply
        0
        • H Hema Bairavan

          Hi i am doing an web application , in which i have to disable the back button using the C# code. can you please help me?? else, can any one tell some coding in the asp side so that i can paste directly in the page??

          S Offline
          S Offline
          Sundar_R
          wrote on last edited by
          #4

          Hope you are talking about the browser back button. You cannot disable the back button if the browser instance is opened and your URL is typed in the address bar. However you have control over the window which you are opening from your code. So the only way to solve your problem is to have a default startup page in which you have to do a opendialog for your homepage and pass the arguments disbaling the menu bars and titlebars.

          H 1 Reply Last reply
          0
          • S Sundar_R

            Hope you are talking about the browser back button. You cannot disable the back button if the browser instance is opened and your URL is typed in the address bar. However you have control over the window which you are opening from your code. So the only way to solve your problem is to have a default startup page in which you have to do a opendialog for your homepage and pass the arguments disbaling the menu bars and titlebars.

            H Offline
            H Offline
            Hema Bairavan
            wrote on last edited by
            #5

            mr sundar, its ok , i understand and know what you are telling. thanks for replying. but the scenario here is, i am calling this page from a third party say like pay pal(after success full trans). in this case how can i give those things like disabling browsing button and all, can u please rpely

            S 1 Reply Last reply
            0
            • H Hema Bairavan

              mr sundar, its ok , i understand and know what you are telling. thanks for replying. but the scenario here is, i am calling this page from a third party say like pay pal(after success full trans). in this case how can i give those things like disabling browsing button and all, can u please rpely

              S Offline
              S Offline
              Sundar_R
              wrote on last edited by
              #6

              Sorry, i am not getting you. Can you paste the code here ?

              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