title: Reset the session timeout when the Yes button of the modal popup is clicked
body: <p>I want the session timeout to reset when the YES button of the Modal Popup  is clicked. At the moment the JavaScript code just hide the Modal pop up. Everything else is working as it should. Thanks</p>
  
  <p>HTLML Code</p>
  
  <pre><code>  &lt;asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"&gt;
    &lt;/asp:ToolkitScriptManager&gt;
      &lt;h3&gt;Session Idle:&amp;nbsp;&lt;span id="secondsIdle"&gt;&lt;/span&gt;&amp;nbsp;seconds.   &lt;/h3&gt;
     &lt;asp:LinkButton ID="lnkFake" runat="server" /&gt;
     &lt;asp:ModalPopupExtender ID="mpeTimeout" BehaviorID ="mpeTimeout"  runat="server" PopupControlID="pnlPopup" TargetControlID="lnkFake"
        OkControlID="btnYes" CancelControlID="btnNo"  BackgroundCssClass="modalBackground" OnOkScript = "ResetSession()"&gt;
  &lt;/asp:ModalPopupExtender&gt;
   &lt;asp:Panel ID="pnlPopup" runat="server" CssClass="modalPopup" Style="display: none"&gt;
  &lt;div class="header"&gt;
      Session Expiring!
  &lt;/div&gt;
  &lt;div class="body"&gt;
      Your Session will expire in&amp;nbsp;&lt;span id="seconds"&gt;&lt;/span&gt;&amp;nbsp;seconds.&lt;br /&gt;
      Do you want to reset?
  &lt;/div&gt;
  &lt;div class="footer" align="right"&gt;
      &lt;asp:Button ID="btnYes" runat="server" Text="Yes" CssClass="yes" /&gt;
      &lt;asp:Button ID="btnNo" runat="server" Text="No" CssClass="no" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>I want the JavaScript code to handle the session reset at the moment the code just hide the modal popup</p>
  
  <p>JavaScript code</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
      function SessionExpireAlert(timeout) {
          var seconds = timeout / 1000;
          document.getElementsByName("secondsIdle").innerHTML = seconds;
          document.getElementsByName("seconds").innerHTML = seconds;
          setInterval(function () {
              seconds--;
              document.getElementById("seconds").innerHTML = seconds;
              document.getElementById("secondsIdle").innerHTML = seconds;
          }, 1000);
          setTimeout(function () {
              //Show Popup before 20 seconds of timeout.
              $find("mpeTimeout").show();
          }, timeout - 20 * 1000);
          setTimeout(function () {
              window.location = "Login.aspx";
          }, timeout);
      };
      function ResetSession() {
          // Hide Modal Popup
          $find('mpeTimeout').hide();
  
          // Reset Session Here
  
      }
  
      &lt;/script&gt;
  </code></pre>
  
  <p>C# Code</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
   {
         Response.Cache.SetCacheability(HttpCacheability.NoCache);
      if (this.IsPostBack)
      {
          Session["Reset"] = true;
          Configuration config =   WebConfigurationManager.OpenWebConfiguration("~/Web.Config");
         SessionStateSection section = (SessionStateSection)config.GetSection("system.web/sessionState");
         int timeout = (int)section.Timeout.TotalMinutes * 1000 * 60;
         ClientScript.RegisterStartupScript(this.GetType(), "SessionAlert", "SessionExpireAlert(" + timeout + ");", true);
       }
    }
  </code></pre>