title: Controls' visibility property, modified by JavaScript, is ignored after postback
body: <p>My javascript code modifies some properties, visibility included. After postback, some properties stuck, others are "forgotten". Here I try to change the Text property of a textbox and the visibility property of a label to 'hidden'. After postback, the text is preserved, but the label is shown. I would very much like to keep the label hidden after the postback. The same occurs with the 'display' CSS property. Or, if I try to hide a <code>&lt;div&gt;</code>. Any help would be very much appreciated:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowHide.aspx.cs" Inherits="WebApplication1.ShowHide" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;Untitled Page&lt;/title&gt;
      &lt;script type="text/javascript" language="javascript"&gt;
          function ShowHide()
          {
              debugger;
              var txt = document.getElementById('txtNumber');
              txt.value='4';
              var lbl = document.getElementById('lblShowHide');
              if(lbl.style.visibility == 'hidden')
              {
                  lbl.style.visibility = '';
              }
              else
              {
                  lbl.style.visibility = 'hidden';
              }
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
          &lt;asp:Label ID="lblNumber" runat="server" Text="Enter Number" /&gt;
          &lt;asp:TextBox ID="txtNumber" runat="server" Text="5" /&gt;
          &lt;asp:Label ID="lblShowHide" runat="server" Text="Show" /&gt;
          &lt;input id="btnChangeByJS" type="button" value="HTML Change by JavaScript" onclick="ShowHide();" /&gt;
          &lt;asp:Button ID="cmdSubmit" runat="server" Text="ASP Submit" /&gt;
          &lt;asp:HiddenField ID="hfShowHide" runat="server" /&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thank you!</p>