title: Unable to get property 'style' of undefined or null reference
body: <p>I have been looking online for a Watermark effect for my textboxes to get some help and found a piece of code which looks like the following :</p>
  
  <p><strong>Javascript:</strong></p>
  
  <pre><code>function WaterMark(objtxt, event) {
  var defaultText = "Username";
  var defaultpwdText = "Password";
  // Condition to check textbox length and event type
  if (objtxt.id == "tb_Username" || objtxt.id == "tb_Password") {
      if (objtxt.value.length == 0 &amp; event.type == "blur") {
          //if condition true then setting text color and default text in textbox
          if (objtxt.id == "tb_Username") {
              objtxt.style.color = "Gray";
              objtxt.value = defaultText;
          }
          if (objtxt.id == "tb_Password") {
              document.getElementById("&lt;%= tb_TempPassword.ClientID %&gt;").style.display = "block";
              objtxt.style.display = "none";
          }
      }
  }
  // Condition to check textbox value and event type
  if ((objtxt.value == defaultText || objtxt.value == defaultpwdText) &amp; event.type == "focus") {
      if (objtxt.id == "tb_Username") {
          objtxt.style.color = "black";
          objtxt.value = "";
      }
      if (objtxt.id == "tb_TempPassword") {
          objtxt.style.display = "none";
          document.getElementById("&lt;%= tb_Password.ClientID %&gt;").style.display = "";
          document.getElementById("&lt;%= tb_Password.ClientID %&gt;").focus();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Then the HTML</strong>: </p>
  
  <pre><code>&lt;asp:TextBox runat="server" ID="tb_Username" Text="Username" onblur="WaterMark(this, event);" onfocus="WaterMark(this, event);" /&gt;
  
  &lt;asp:TextBox runat="server" ID="tb_TempPassword" Text="Password" onfocus="WaterMark(this, event);" ForeColor="Gray" /&gt;
  
  &lt;asp:TextBox runat="server" ID="tb_Password" TextMode="Password" text="Password" Style="display:none" onblur="WaterMark(this, event);"/&gt;
  </code></pre>
  
  <p>But for some reason when i run my code the Username box works fine but the password box comes up with an error saying:</p>
  
  <p><code>0x800a138f - JavaScript runtime error: Unable to get property 'style' of undefined or null reference</code></p>
  
  <p>I have been looking online for a fix and nothing is working? 
  Is this because my Textbox is linking to a CSS stylesheet?</p>
  
  <p>Any help would be greatly appreciated. </p>