title: Validator in <noscript> causes JavaScript error
body: <p>The following .NET 3.5 code, placed in an aspx file, will trigger a JavaScript error when the page is loaded (for users who have JavaScript enabled):</p>
  
  <pre><code>&lt;noscript&gt;
      &lt;asp:TextBox ID="txt" runat="server"&gt;&lt;/asp:TextBox&gt;
      &lt;asp:RequiredFieldValidator ID="txt_RequiredFieldValidator" runat="server" 
        ControlToValidate="txt"&gt;&lt;/asp:RequiredFieldValidator&gt;
      &lt;asp:Button ID="btn" runat="server" Text="Button" /&gt;
  &lt;/noscript&gt;
  </code></pre>
  
  <p>The error happens because the JavaScript generated by the ASP.NET validator control does not contain a null check on before the second code line below:</p>
  
  <pre><code>var ctl00_body_txt_RequiredFieldValidator =
    document.all ?
      document.all["ctl00_body_txt_RequiredFieldValidator"] :
      document.getElementById("ctl00_body_txt_RequiredFieldValidator");
  
  ctl00_body_txt_RequiredFieldValidator.controltovalidate = "ctl00_body_txt";
  </code></pre>
  
  <p>Can anyone suggest a workaround to this?</p>
  
  <p><hr/>
  <em>Footnote:</em> Why am I doing this? For my non-JavaScript users I am replacing some AJAX functionality with some different UI components, which need validation.</p>