Wednesday 13 March 2013

Disable Browser Back Button functionality after click on Logout Button


Description:-


                  in this example we explain that how to disable the back button of browser when logout from the site. the main use of this application is that once you logout you are redirect to the login page and then you can click on browser back button then you can not move to back because of this code that are defined below. in some application you see that once you logout from the site you redirect to login page and click on browser back button then it will redirect back to logout page.

We all know that Today Every Social Networking site Provide this Facility that once user Logout from the site so Browser Back Button is Disable so user can not Go Back because user Session is Remove From the Browser.

you have Download one gif image of Loading Display when Logout button is clicked. main thing Remember that must Define Session null Before Redirect to Login page when click on Logout page.

This Example provide better Security to Restrict the dummy user.


to show Example of ModalPopup For Insert,Update,Delete ModalPopup For CRUD operation

How to Send SMS in Asp.Net Send SMS to user Mobile



Default2.aspx:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Disable Browser Back Button Fuctionality when user is Logout</title>
       <script language="javascript" type="text/javascript">
           //Function for Disable Browser back Button
           function DisableBrowserBackButton() {
               window.history.forward(1);
           }
           setTimeout("DisableBrowserBackButton()", 0);
           window.onunload = function () { null }
</script>
</head>
<body >
    <form id="form1" runat="server">
   <div>
Go to Third page
</div>
<div>

<asp:Button ID="btnprevious" runat="server" Text="Move to SecondPage" PostBackUrl="~/Default2.aspx" />
<asp:Button ID="btnnext" runat="server" Text="Move to ThirdPage" PostBackUrl="~/Default3.aspx" />
</div>
    </form>
</body>
</html>





Default3.aspx:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Disable Browser Back Button Fuctionality when user is Logout</title>
    <script language="javascript" type="text/javascript">
        //Function for Disable Browser back Button
        function DisableBrowserBackButton() {
            window.history.forward(1);
        }
        setTimeout("DisableBrowserBackButton()", 0);
        window.onunload = function () { null }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            Go to Second page
        </div>
        <div>

            <asp:Button ID="btnprevious" runat="server" Text="Move to SecondPage" PostBackUrl="~/Default2.aspx" />
            <asp:Button ID="btnnext" runat="server" Text="Move to ThirdPage" PostBackUrl="~/Default3.aspx" />
        </div>
    </form>
</body>
</html>


0 comments:

Post a Comment