Click here to Skip to main content
15,880,905 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: adding item in listbox using delegate Pin
Barbo28-Dec-11 4:54
Barbo28-Dec-11 4:54 
GeneralRe: adding item in listbox using delegate Pin
jhyn28-Dec-11 16:39
jhyn28-Dec-11 16:39 
QuestionProblem in run website Pin
Jitendra Parida - Jeetu26-Dec-11 20:35
Jitendra Parida - Jeetu26-Dec-11 20:35 
AnswerRe: Problem in run website Pin
thatraja26-Dec-11 21:09
professionalthatraja26-Dec-11 21:09 
Questionhow to remove session when browser closed. Pin
uspatel25-Dec-11 23:14
professionaluspatel25-Dec-11 23:14 
AnswerRe: how to remove session when browser closed. Pin
Jitendra Parida - Jeetu26-Dec-11 2:09
Jitendra Parida - Jeetu26-Dec-11 2:09 
GeneralRe: how to remove session when browser closed. Pin
uspatel26-Dec-11 18:50
professionaluspatel26-Dec-11 18:50 
GeneralRe: how to remove session when browser closed. Pin
Jitendra Parida - Jeetu26-Dec-11 20:50
Jitendra Parida - Jeetu26-Dec-11 20:50 
try this:

1. First create a page LogOut.aspx and in Page_Load event write this code:-


C#
protected void Page_Load(object sender, EventArgs e)
{
    Session.Abandon();
}


2. Then add following JavaScript code in your page or Master Page:-

JavaScript
<script type="text/javascript"> 

    var clicked = false;
   function CheckBrowser()
     {
        if (clicked == false)
        {
            //Browser closed
        }
        else
        {
            //redirected 
            clicked = false;
        }
    }
 
    function bodyUnload()
    {
        if (clicked == false)//browser is closed
        {
        var request = GetRequest();
           
        request.open  ("GET", "AutoLogOut.aspx", true);
        request.send();
        }
    }
 
    function GetRequest()
    {
        var request = null;
        if (window.XMLHttpRequest)
        {
            //incase of IE7,FF, Opera and Safari browser
            request = new XMLHttpRequest();
        }
        else
        {
            //for old browser like IE 6.x and IE 5.x
            request = new ActiveXObject('MSXML2.XMLHTTP.3.0');
        }
        return request;
    } 


3. Add the following code in the body tag of master page.

HTML
<body onunload="bodyUnload();" Onclick="clicked=true;">


Finally the code in Master page like this:-


JavaScript
<script language="javascript" type="text/javascript">
    //<![CDATA[

    var clicked = false;
    function CheckBrowser() {
        if (clicked == false) {
            //Browser closed
        }
        else {
            //redirected 
            clicked = false;
        }
    }

    function bodyUnload() {
        if (clicked == false)//browser is closed
        {
            //var request = GetRequest();
           
            //location.href = 'LogOut.aspx';
            var request = GetRequest();

            request.open("GET", "LogOut.aspx", true);
            request.send();
        }
    }
    function GetRequest() {
        var request = null;
        if (window.XMLHttpRequest) {
            //incase of IE7,FF, Opera and Safari browser
            request = new XMLHttpRequest();
        }
        else {
            //for old browser like IE 6.x and IE 5.x
            request = new ActiveXObject('MSXML2.XMLHTTP.3.0');
        }
        return request;
    } 
 

    
    //]]>
</script>

ASP.NET
<body onunload="bodyUnload();" onclick="clicked=true;">
    <form id="form1" runat="server">

Questionmaintaining old data Pin
sheemap25-Dec-11 18:41
sheemap25-Dec-11 18:41 
AnswerRe: maintaining old data Pin
uspatel25-Dec-11 23:53
professionaluspatel25-Dec-11 23:53 
Questionhow to create a mail website like gmail Pin
Bhagawati.joshi22-Dec-11 20:09
Bhagawati.joshi22-Dec-11 20:09 
AnswerRe: how to create a mail website like gmail Pin
R. Giskard Reventlov22-Dec-11 21:15
R. Giskard Reventlov22-Dec-11 21:15 
QuestionHow can i include Jquery.js in master page? Pin
buffering8322-Dec-11 14:12
buffering8322-Dec-11 14:12 
AnswerRe: How can i include Jquery.js in master page? Pin
R. Giskard Reventlov22-Dec-11 21:14
R. Giskard Reventlov22-Dec-11 21:14 
QuestionAny tips on how I would submit a search request? Pin
unity31122-Dec-11 8:24
unity31122-Dec-11 8:24 
QuestionI Want a project using Global.asax file Pin
RashdSiddique22-Dec-11 1:35
RashdSiddique22-Dec-11 1:35 
AnswerRe: I Want a project using Global.asax file Pin
Shahriar Iqbal Chowdhury/Galib22-Dec-11 9:50
professionalShahriar Iqbal Chowdhury/Galib22-Dec-11 9:50 
GeneralRe: I Want a project using Global.asax file Pin
RashdSiddique22-Dec-11 22:05
RashdSiddique22-Dec-11 22:05 
GeneralRe: I Want a project using Global.asax file Pin
AprNgp26-Dec-11 17:48
AprNgp26-Dec-11 17:48 
Questionhow to send emails in asp.net(without IIS throught smtp) Pin
MalarGayu21-Dec-11 11:45
MalarGayu21-Dec-11 11:45 
AnswerRe: how to send emails in asp.net(without IIS throught smtp) Pin
Not Active21-Dec-11 12:29
mentorNot Active21-Dec-11 12:29 
GeneralRe: how to send emails in asp.net(without IIS throught smtp) Pin
MalarGayu21-Dec-11 12:58
MalarGayu21-Dec-11 12:58 
GeneralRe: how to send emails in asp.net(without IIS throught smtp) Pin
Not Active21-Dec-11 13:47
mentorNot Active21-Dec-11 13:47 
AnswerRe: how to send emails in asp.net(without IIS throught smtp) Pin
Dalek Dave21-Dec-11 13:27
professionalDalek Dave21-Dec-11 13:27 
JokeRe: how to send emails in asp.net(without IIS throught smtp) Pin
Manfred Rudolf Bihy21-Dec-11 13:47
professionalManfred Rudolf Bihy21-Dec-11 13:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.