learned/learning/to learn RSS 2.0
# Wednesday, 30 September 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">

</cc1:ModalPopupExtender>

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

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

        <tr valign="top">

            <th>

                Prompt Message

            </th>

        </tr>

        <tr>

            <td>               

                        <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" />

            </td>

        </tr>

    </table>

</asp:Panel>

 

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

        $find('popup_promptmessage').show();

    }

 

    // handles closing popup

    function ResetSession() {

        $find('popup_promptmessage').hide();

    }

 

    // 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”;

    }   

  

 </script>

 

Thanks.

Wednesday, 30 September 2009 19:55:52 (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
.NET
Comments are closed.
Navigation
Archive
<2017 October>
SunMonTueWedThuFriSat
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234
About the author/Disclaimer

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

© Copyright 2017
Gokulnath
Sign In
Statistics
Total Posts: 41
This Year: 0
This Month: 0
This Week: 0
Comments: 47
Themes
Pick a theme:
All Content © 2017, 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.