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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Handling browser(<--) and (-->) buttons

Handling browser(<--) and (-->) buttons

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptdesignsysadmintools
5 Posts 3 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.
  • K Offline
    K Offline
    K V Sekhar
    wrote on last edited by
    #1

    Hi all, I wants not allow user to revisit the previous pages once he logged out. I am using master page, in that i placed a logout linkbutton. When user clicks on logout button, i am redirecting user to loginpage.aspx. In the Design of loginpage.aspx i wrote the following javascript to prevent user to navigate through browser -> & <- buttons. LoginPage.aspx: <%@ Page Language="C#" MasterPageFile="~/ProxyAds.master" AutoEventWireup="true" CodeFile="LoginPage.aspx.cs" Inherits="LoginPage" %> <asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="server"> <script language="javascript" type= "text/javascript"> if (window.history) { window.history.forward(1); } </script> <div id="home"> //Login Controls here.... </div> </asp:Content> ......................... But its not working. any thing i am doing wrong ? please suggest me. thanks in advance.

    B D 2 Replies Last reply
    0
    • K K V Sekhar

      Hi all, I wants not allow user to revisit the previous pages once he logged out. I am using master page, in that i placed a logout linkbutton. When user clicks on logout button, i am redirecting user to loginpage.aspx. In the Design of loginpage.aspx i wrote the following javascript to prevent user to navigate through browser -> & <- buttons. LoginPage.aspx: <%@ Page Language="C#" MasterPageFile="~/ProxyAds.master" AutoEventWireup="true" CodeFile="LoginPage.aspx.cs" Inherits="LoginPage" %> <asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="server"> <script language="javascript" type= "text/javascript"> if (window.history) { window.history.forward(1); } </script> <div id="home"> //Login Controls here.... </div> </asp:Content> ......................... But its not working. any thing i am doing wrong ? please suggest me. thanks in advance.

      B Offline
      B Offline
      balaji t
      wrote on last edited by
      #2

      hi, try giving like this window.history.forward(-1)

      T.Balaji

      K 1 Reply Last reply
      0
      • K K V Sekhar

        Hi all, I wants not allow user to revisit the previous pages once he logged out. I am using master page, in that i placed a logout linkbutton. When user clicks on logout button, i am redirecting user to loginpage.aspx. In the Design of loginpage.aspx i wrote the following javascript to prevent user to navigate through browser -> & <- buttons. LoginPage.aspx: <%@ Page Language="C#" MasterPageFile="~/ProxyAds.master" AutoEventWireup="true" CodeFile="LoginPage.aspx.cs" Inherits="LoginPage" %> <asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="server"> <script language="javascript" type= "text/javascript"> if (window.history) { window.history.forward(1); } </script> <div id="home"> //Login Controls here.... </div> </asp:Content> ......................... But its not working. any thing i am doing wrong ? please suggest me. thanks in advance.

        D Offline
        D Offline
        Dilip H Patel
        wrote on last edited by
        #3

        Hi Shekhar, Dilip Here. In such situations, why don't you use window.histoty.delete. But i am suggesting to use C# backcode to handle such situations. when user log in, you would store his userid in session. when user log out you would delete userid from session. when user passes any request (either with browser back button or giving url in addressbar), you can check in page load event whether user is loggin or not. if not than you can redirect page to login page Regards Dilip Patel

        K 1 Reply Last reply
        0
        • D Dilip H Patel

          Hi Shekhar, Dilip Here. In such situations, why don't you use window.histoty.delete. But i am suggesting to use C# backcode to handle such situations. when user log in, you would store his userid in session. when user log out you would delete userid from session. when user passes any request (either with browser back button or giving url in addressbar), you can check in page load event whether user is loggin or not. if not than you can redirect page to login page Regards Dilip Patel

          K Offline
          K Offline
          K V Sekhar
          wrote on last edited by
          #4

          Thanks dilip, thanks for ur suggestion. I implemented that also, with this the ploblem is when user hits browser(<- & ->) buttons control, some times is not comming into PageLoad event. I checked by placing BreakPont on Pageload. May be the reason is Browser is catching the previous pages when we hit <- buttons it simply displays the page. If i put the above logic in MasterPage working fine,but the problem is it totally not allowing user to navigate through browser buttons. through out the application it is not allowing. I dont want that kind of functionality. I only wants user to not allow to visit previous pages only after he logged out from site. Is that ok place Script in LoginPage.aspx ? bcz its the home page. Please suggest me, Thanks in advance.

          1 Reply Last reply
          0
          • B balaji t

            hi, try giving like this window.history.forward(-1)

            T.Balaji

            K Offline
            K Offline
            K V Sekhar
            wrote on last edited by
            #5

            Thanks balaji, thanks for ur suggestion. There is nothing wrong in that logic, its woks fine.I already tested that logic by placing that on MasterPage. But the problem is it totally not allowing user to navigate through browser buttons. through out the application it is not allowing. I dont want that kind of functionality. I only wants user to not allow to visit previous pages only after he logged out from site. Is that ok place Script in LoginPage.aspx ? bcz its the home page. Please suggest me, Thanks in advance.

            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