session timeout warning problem



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() {
resizable: true,
width: 400,
heigh: 450,
modal: true,
show: 'Transfer',
hide: 'Transfer'

function CloseSessionTimeoutModalWin() {
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.";


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();
<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">
<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;" />
<input id="ButtonTest" type="button" value="Test No" onclick="CloseSessionTimeoutModalWin(); return false;" />

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question