title: Asp:RequiredFieldValidator causes validation on Server even if validator is disabled
body: <p>I will keep this as short as possble but its wrecking my head. I have a user control with a label and a field. I add the user control dynamically to a page at run time. There could be many user controls which are built dynamically from data I get from the data base. The data describes the label name and if the text box should be completed.. ie is it required. I have a submit on the main page which has a validation group.All the validators on the user controls have the same validation group. So far so good I hope.</p>
  
  <p>The user control has a RequiredFieldValidator for the text box and looks all like this. The validator is enabled by default.</p>
  
  <pre><code>&lt;asp:TextBox ID="dfControl" runat="server" Text="" ToolTip="ucsAlphanumericEntryDC" Width="95%" CausesValidation="true"/&gt;
  &lt;asp:RequiredFieldValidator ID="rfvContol" runat="server" ErrorMessage="Value is required" EnableClientScript="true" 
      ValidationGroup="ValidateContols" ControlToValidate="dfControl" Display="Dynamic" Enabled="true"&gt;&lt;/asp:RequiredFieldValidator&gt;
  </code></pre>
  
  <p>When I dynamically load the control I check a parameter to tell me if the field is required or not. The paramater is from the database which represents the control that I am about to draw. If the Field NOT a required field I disable the validation in the page_preRender.. also tried it in load.</p>
  
  <pre><code>       if (!DisplayRequired)
          {
              rfvContol.EnableClientScript = false;
              rfvContol.Enabled = false;
              dfControl.CausesValidation = false;
          }
  </code></pre>
  
  <p>So far so good. This all works on the client side validation for only the user controls with the Display Required set to true, leaving the Validator enabled.</p>
  
  <p>however on posting page from a submit button which I have wired to the same validation group as the user controls, I check the IsValid on the submit and if its false I dont save anything. But when the page re-renders on the client.. I have error messages on all the user controls, saying that they are required... even though I disabled some of them that where not required. the View state is default on the control which I assume to be on.</p>
  
  <p>I also tried not redrawing the controls with the validators, by enclosing the code in a if(!IsPostBack)</p>
  
  <p>Has anyone any idea's why the validators fire when they are disabled on the first page load but dont get disabled on the postback.</p>
  
  <p>thanks Mick</p>