Results 1 to 4 of 4

Thread: JavaScript to Show time countdown display after .net session timeout

  1. #1
    Join Date
    Jan 2009
    Posts
    124

    JavaScript to Show time countdown display after .net session timeout

    I would like to know that, is it possible for me to have a javascript which will display the time countdown minutes automatically after the net session timeout gets over. Can any body tell me that how can i do it? Does any body have any idea about the above issue? Kindly provide me the correct logical solution for the above issue.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: JavaScript to Show time countdown display after .net session timeout

    Just follow teh below steps mention.

    <script type="text/javascript">
    var sessionTimeout = "<%= Session.Timeout %>";
    function DisplaySessionTimeout()
    {
    //assigning minutes left to session timeout to Label
    document.getElementById("<%= lblSessionTime.ClientID %>").innerText =
    sessionTimeout;
    sessionTimeout = sessionTimeout - 1;

    //if session is not less than 0
    if (sessionTimeout >= 0)
    //call the function again after 1 minute delay
    window.setTimeout("DisplaySessionTimeout()", 60000);
    else
    {
    //show message box
    alert("Your current Session is over.");
    }
    }
    </script>
    Hope so it may help you out.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: JavaScript to Show time countdown display after .net session timeout

    The best advice would probably be to ask the users to close the browser window once they're done. With the use of session-cookies, the session will automatically end when the browser is closed or otherwise on a 30 minute timeout. Since there by default is no interaction between the browser and the server once a page is loaded, you would have to have a javascript contact the server in the background on forms-pages to refresh the session.

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: JavaScript to Show time countdown display after .net session timeout

    Begin by creating a new ASP.NET Server Control project called SessionTimeoutTool. This will generate both a project and a solution for you. Add a second ASP.NET Web project to the solution called TestTimeoutTool. Open the web.config file for TestTimeoutTool and add a sessionState element in order to set the session timeout period. For the purposes of testing this control, it is advisable to set this attribute to something small.

    <system.web>
    <sessionState timeout="2" mode="InProc"/>
    </system.web>
    This establishes the control development environment.

    Rename the default class in the SessionTimeoutTool project by right clicking on the default class in the Solution Explorer and renaming the file from ServerControl1.cs to TimeoutWatcherControl. The IDE will take care of renaming your class for you. The TimeoutWatchControl class comes with the Text property and the RenderContents already implemented for you by the IDE. You may delete these. You may also safely remove the ToolboxData and DefaultProperty attributes that decorate your class declaration.

    namespace SessionTimeoutTool
    {
    public class TimeoutWatcherControl : WebControl
    {
    }
    }

Similar Threads

  1. Replies: 3
    Last Post: 02-07-2012, 04:08 PM
  2. Countdown, redirects and text loader in Javascript
    By Xiomar in forum Tips & Tweaks
    Replies: 1
    Last Post: 24-11-2010, 06:17 AM
  3. How to do Slide Show using JavaScript?
    By Samarth in forum Software Development
    Replies: 5
    Last Post: 03-02-2010, 07:03 AM
  4. Replies: 2
    Last Post: 20-06-2009, 12:16 PM
  5. To show the session timeout in ASP.NET
    By Vaibhav S in forum Software Development
    Replies: 2
    Last Post: 03-02-2009, 11:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,826,192.82234 seconds with 17 queries