<asp:LinkButton ID="lnkFake" runat="server" /> <asp:ModalPopupExtender ID="mpeTimeout" BehaviorID="mpeTimeout" runat="server" PopupControlID="pnlPopup" TargetControlID="lnkFake" OkControlID="btnYes" BackgroundCssClass="modalBackground" OnOkScript="ResetSession()"> </asp:ModalPopupExtender> <asp:Panel ID="pnlPopup" runat="server" CssClass="modalPopup" Style="display: none"> <div class="header"> Session Expiring! </div> <div class="body"> Your Session will expire in <span id="seconds"></span> seconds.<br /> Do you want to reset? </div> <div class="btnSection" align="right"> <asp:Button ID="btnYes" runat="server" Text="OK" CssClass="yes" /> <%-- <asp:Button ID="btnNo" runat="server" Text="No" CssClass="no" />--%> </div> </asp:Panel>
<script type="text/javascript"> var myTimer; var myTimer2; var myTimer3; function SessionExpireAlert(timeout) { var seconds = timeout / 1000; // document.getElementsByName("secondsIdle").innerHTML = seconds; document.getElementsByName("seconds").innerHTML = seconds; myTimer = setInterval(function () { seconds--; document.getElementById("seconds").innerHTML = seconds; // document.getElementById("secondsIdle").innerHTML = seconds; }, 1000); myTimer2=setTimeout(function () { //Show Popup before 20 seconds of timeout. // alert('hi'); $find("mpeTimeout").show(); }, timeout - 60 * 1000); myTimer3 = setTimeout(function () { //alert(" Your Session has expired."); window.location = '<%=ResolveUrl("~/CRM/Login.aspx") %>'; // window.location = "Expired.aspx"; }, timeout); }; function ResetSession() { //Redirect to refresh Session. //window.location = window.location.href; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: '<%=ResolveUrl("~/CRM/Login.aspx/ResetSession") %>', dataType: "json", success: function (data) { clearInterval(myTimer); clearInterval(myTimer2); clearInterval(myTimer3); SessionExpireAlert(data.d); }, error: function (result) { alert("Error"); } }); } </script>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)