title: Page_ClientValidate() object expected error, cant find the validator
body: <p>I have a form HomePage.aspx containing an empty asp:Panel, a dropdownlist letting the user pick an SPFielType... on index changed, my HomePage.aspx.cs page will get the text selected and will load a user control inside the panel, this user control will generate a control based on the spfieldtype  chosen by the user and a button calling the validateForm() function... my problem is that the Page_ClientValidate() function inside the validateForm() cant find the validator, i also tried to give a groupname but still not working.  <br/>
  When Im putting the button inside my aspx page (not rendering dynamically) it is validating my page.( <code>&lt;asp:Button ID="submitbutton" Text="Validate" runat="server" /&gt;</code>).<br/>
  But when Im rendering it dynamically , cant validate the form..This is what Im trying to do:</p>
  
  <pre><code>protected override void CreateChildControls()
  {
      try
      {
          fieldRenderingControl = this.CreateFieldRenderingControl(this.FieldType);
          this.Controls.Add(fieldRenderingControl);
  
          Button button = new Button();
          button.UseSubmitBehavior = false;
          button.Text = "ValidateButton";
          button.ID = "ValidateButton";
          button.OnClientClick = "validateForm()";
          this.Controls.Add(button);
  
          RequiredFieldValidator newValidator = new RequiredFieldValidator();
          newValidator.Text = "***";
          newValidator.ID = "valideee";
          newValidator.EnableClientScript = true;
          newValidator.Enabled = true;
          newValidator.SetFocusOnError = true;
          newValidator.Display = ValidatorDisplay.Dynamic;
          newValidator.ControlToValidate = fieldRenderingControl.ID;
          this.Controls.Add(newValidator);
  
      }
      catch (Exception ex)
      {
      }
  
  }
  </code></pre>
  
  <p>// the CreateFieldRenderingControl() function will generate a control based on the argument fieldType chosen by the user.</p>
  
  <p>thanks in advance.</p>