This is a migrated thread and some comments may be shown as answers.

Request for Session time out alert with master page

1 Answer 200 Views
ScriptManager and StyleSheetManager
This is a migrated thread and some comments may be shown as answers.
Pravallika
Top achievements
Rank 1
Pravallika asked on 09 Jul 2014, 08:47 AM
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() {
                $find('mpe_alert').show();
            }
            function hide() {
                $find('mpe_alert').hide();
            }
            function onOk() {
                $find('mpe_alert').hide();
                _doPostBack($find('btnOk'), '')
            }
my .aspx page
<body>
    <form id="form1" runat="server">
        <%--  <asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="180" ScriptMode="Release" EnableScriptGlobalization="true" EnablePageMethods="true" >
    </asp:ScriptManager>--%>
        <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()">
            </cc1:ModalPopupExtender>
            <asp:Panel ID="pnlAlert" runat="server" Height="100px"
                Style="display: none" Width="250px">
                <table width="100%">
                    <tr>
                        <td align="left" style="font-weight: bold; font-family: Arial">
                            <asp:Label ID="lblSessionAlert" runat="server" Text="Session Expiry Alert"></asp:Label>
                    </tr>
                </table>
                <table>
                    <tr>
                        <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>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <br />
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <asp:Button Text="Yes" value="Yes" runat="server" ID="btnOk" />
                        </td>
                        <td align="left">
                            <asp:Button Text="Cancel" value="No" runat="server" ID="btnCancel" />
                        </td>
                    </tr>
                </table>
            </asp:Panel>
  
        </div>
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");

1 Answer, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 14 Jul 2014, 07:49 AM
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.

Regards,
Genady Sergeev
Telerik
 

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.

 
Tags
ScriptManager and StyleSheetManager
Asked by
Pravallika
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Share this question
or