Request for Session time out alert with master page

2 posts, 0 answers
  1. Pravallika
    Pravallika avatar
    30 posts
    Member since:
    Mar 2014

    Posted 09 Jul 2014 Link to this post

    Hai All,
    I am using ajaxtoolkit’s modalpopupextender control to alert user about expiring session.what i need for every 5mins if the site is ideal it will show alert message your seesion is expering if u want to extend if it is ok then u have reset the time like that for that
    i wrote my code like this.but dnt knw i am getting error in script its not wroking properly can any one tel me how to do this task

    <script type="text/javascript">
                function ShowAlert() {
                function hide() {
                function onOk() {
                    _doPostBack($find('btnOk'), '')
    my .aspx page
        <form id="form1" runat="server">
            <%--  <asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="180" ScriptMode="Release" EnableScriptGlobalization="true" EnablePageMethods="true" >
            <telerik:RadScriptManager  runat="server" ID="RadScriptManager1" EnablePageMethods="true" />
            <telerik:RadSkinManager ID="QsfSkinManager"  runat="server" Skin="Metro" ShowChooser="false" />
       <asp:HiddenField ID="hdnSessionExpire" runat="server" />
                <cc1:ModalPopupExtender ID="mpe_alert"  runat="server" TargetControlID="hdnSessionExpire"
                    PopupControlID="pnlAlert" CancelControlID="btnCancel" OkControlID="btnOk" BehaviorID="mpe_alert"  önOkScript="onOk()">
                <asp:Panel ID="pnlAlert" runat="server" Height="100px"
                    Style="display: none" Width="250px">
                    <table width="100%">
                            <td align="left" style="font-weight: bold; font-family: Arial">
                                <asp:Label ID="lblSessionAlert" runat="server" Text="Session Expiry Alert"></asp:Label>
                            <td colspan="2">
                                <asp:Label ID="lblMessage" runat="server" Font-Bold="true" Text="Your session is going to expire in 1 minute. Would you like to extend your session?"></asp:Label>
                                <br />
                            <td align="right">
                                <asp:Button Text="Yes" value="Yes" runat="server" ID="btnOk" />
                            <td align="left">
                                <asp:Button Text="Cancel" value="No" runat="server" ID="btnCancel" />
    my .cs file in page load 
    Session.Timeout = 5;
                int MillisecondsTimeout = (Session.Timeout * 60000) - 120000;
                string strScriptAlert = @"window.setInterval('ShowAlert()' , " + MillisecondsTimeout.ToString() + @");   ";
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", strScriptAlert, true);
                int Timeout = (Session.Timeout * 60000) - 60000;
                string strScriptHideAlert = @"window.setInterval('hide()' , " + Timeout.ToString() + @");   ";
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "HideAlert", strScriptHideAlert, true);
                Response.AppendHeader("Refresh", Convert.ToString((Session.Timeout * 60)) + ";URL=Login.aspx");
  2. Genady Sergeev
    Genady Sergeev avatar
    1595 posts

    Posted 14 Jul 2014 Link to this post

    Hi  Pravallika,

    Thank you for contacting the Telerik support.

    Please note that such request are outside of the support scope because we don't provide support for the AJAX Toolkit and generic ASP.NET issues.

    With respect to your problem - you can simply count 5 minutes and prompt a dialog to the user upon then. If they are agree to extend the session you can make dummy AJAX request with the session identifier to notify the server that the client is still active.

    I hope that this information helps.

    Genady Sergeev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. DevCraft R3 2016 release webinar banner
Back to Top