learned/learning/to learn RSS 2.0
# Wednesday, September 30, 2009

This article describes how to notify users about session expiration and allow them to renew the session.

Controls that need to be added:
1. A Panel with an OK button.

2. A label with session expiration notification message.

3. An AJAX ModalPopupExtender.

4. A dummy button and set ModalPopupExtender’s TargetControlId as this button.


This is how it looks:


<cc1:ModalPopupExtender ID="modext_promptmessage" runat="server" BehaviorID="popup_promptmessage"

    PopupControlID="pnl_popup" TargetControlID="btn_dummy">


<asp:Panel ID="pnl_popup" runat="server" Style="display: none">

    <table cellpadding="0" cellspacing="0" border="0">

        <tr valign="top">


                Prompt Message





                        <label>Your session is going to expire in 2 minutes. Please click OK to renew it."></label>

<asp:Button ID="btn_ok" runat="server" OnClientClick="ResetSession()" Text="OK" />






My code behind class looks like this:


   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


      ' checks whether session expired

      If Current.Session.Keys.Count = 0 Then

                        Response.Redirect("sessionexpired.aspx", True)

            Exit Sub

      End If


' Javascript function PromptSessionExpiration() will be called 2 minutes before session expiration (120000 milliseconds)

      Dim strExpireSessionScript As String = String.Format("setTimeout('PromptSessionExpiration()', {0}); ", (Me.Session.Timeout * 60000) - 120000)

      Me.Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "expirescript", strExpireSessionScript, True)


   End Sub


   ''' This click event will renew the session, need not add any code inside it

   Protected Sub btn_ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ok.Click 

   End Sub



My javascript:


<script language="javascript" type="text/javascript">


    function PromptSessionExpiration() {

              // the function below will be triggered at the 125th second

        setTimeout('CheckSessionStatus()', 125000);

        // show popup




    // handles closing popup

    function ResetSession() {




    // this function will be called if user doesn’t respond to the prompt message

    // which will redirect to sessionexpired page

    function CheckSessionStatus() {

            window.location = “sessionexpired.aspx”;






Wednesday, September 30, 2009 7:55:52 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Comments are closed.
<May 2020>
About the author/Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2020
Sign In
Total Posts: 41
This Year: 0
This Month: 0
This Week: 0
Comments: 47
Pick a theme:
All Content © 2020, Gokulnath
DasBlog theme 'Business' created by Christoph De Baene (delarou)
The new movement has made a number of changes. First, precise instantaneous jump calendar display tag heuer replica large switching time is scheduled for midnight. The power required for this process will slowly build up within hours. Furthermore, LANGE 1 escapement now available eccentric balance weight balance wheel and homemade free omega uk watch sprung. Means provided in the hand-carved balance wheel splint omega replica underneath, 21,600 vibrations per hour. This table also hublot replica retains the reliable double-barrel, power reserve of 72 hours.