title: Button toggle div visible property
body: <p>I am working on a web application that requires not an actual logging to the DB, but a verification of data before accessing the menu. I am using a <code>&lt;div&gt;</code> to display an error message of a failed validation. The validation takes place in the code behind. I want the event to be able to change the div's visibility property to be hidden or visible, but it fails as the page gets reloaded and therefore it appears that no change has been made. </p>
  
  <p>In a nutshell:</p>
  
  <pre><code>&lt;div runat="server" id="Errmsg" style="visibility:false"&gt;
  &lt;/div&gt;
  &lt;div id="otherDiv"&gt;
     &lt;asp:TextBox runat="server" ID="IdDepTxt"&gt;&lt;/asp:TextBox&gt;(just as an example)
     &lt;asp:Button ID="AccessBtn"  runat="server" OnClick="AcessBtn_Click" Text="ACCESS"  CausesValidation="False" UseSubmitBehavior="False"&gt;&lt;/asp:Button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Code behind:</p>
  
  <pre><code>private boolean validate_data(string Parm1)
  {
      //some code that connects to a db and looks for Parm1 in a table
  }
  
  protected void AccessBtn_Click(object sender, EventArgs e)
  {
      if (validate_data(IdDepTxt.text))
      {
          Response.Redirect("~/Menu.aspx");
      }
      else
      {
          Errmsg.Visible = true;
      }
  }
  </code></pre>