session timeout warning problem

  • Thread starter Thread starter tingwang18
  • Start date Start date
T

tingwang18

I am using the following code to show a session timeout warning modal popup.. The OK button works. But the NO button and the "Test No" button(which is outside the updatepanel) doesn't work. Everytime "no " is clicked, a new session is started. The other problem is, if "OK" is clicked twice on pages where there are dropdownlists and gridviews, it throws:

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.


Please help.

function OpenSessionTimeoutModalWin() {
$("#divSessionTimeout").dialog({
resizable: true,
width: 400,
heigh: 450,
modal: true,
show: 'Transfer',
hide: 'Transfer'
});
$("#divSessionTimeout").parent().appendTo(jQuery("form:first"));
}

function CloseSessionTimeoutModalWin() {
$("#divSessionTimeout").dialog("close");
}
function SessionWarning() {

var sessionTimeoutWarning = '<%= System.Web.Configuration.WebConfigurationManager.AppSettings["SessionWarning"].ToString()%>';
var sessionTimeout = "<%= Session.Timeout %>";

var sTimeout = parseInt(sessionTimeoutWarning) * 60 * 1000;
var message = "Your session will expire in " + (parseInt(sessionTimeout) - parseInt(sessionTimeoutWarning)) + " minutes. Please click OKto continue your session.";

$("#<%=lblSessionTimeoutMessage.ClientID%>").html(message);

setTimeout("OpenSessionTimeoutModalWin()", sTimeout);

setTimeout("SessionTimeout()", parseInt(sessionTimeout)*60*1000);
}

function SessionTimeout() {

var lblSessionExpire = document.getElementById("<%=lblSessionTimeoutMessage.ClientID%>")
lblSessionExpire.innerHTML = "Your Session has expired."
}

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_pageLoaded(SessionWarning);
</script>
<div id="divSessionTimeout" title="Session Timeout Warning">
<asp:Label ID="lblSessionTimeoutMessage" runat="server" Text="Your session is about to timeout."></asp:Label><br />
<br />
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnSessionTimeoutYes" Style="display: block; margin: 0 auto; width: 100px"
CssClass="button" runat="server" Text="OK" OnClientClick="CloseSessionTimeoutModalWin()"
OnClick="btnSessionTimeoutYes_Click" />
<input style="display: block; margin: 0 auto; width: 100px" id="Button1" type="button"
value="No" class="button" onclick="CloseSessionTimeoutModalWin();return false;" />
</ContentTemplate>
</asp:UpdatePanel>
<input id="ButtonTest" type="button" value="Test No" onclick="CloseSessionTimeoutModalWin(); return false;" />
</div>
 
Back
Top