title: Dynamically creating CustomValidator in server control
body: <p>I have a custom server control which wraps a RadEditor (basically a textarea).  I am trying to add a CustomValidator to it dynamically, but I keep getting this error on initial pageload</p>
  
  <blockquote>
    <p>Unable to find control id 'RadEditor1' referenced by the
    'ControlToValidate' property of ''.</p>
  </blockquote>
  
  <p>This is the code I'm using inside my server control to create the CustomValidator:</p>
  
  <pre><code>protected override void OnInit(EventArgs e)
  {
      var validator = new CustomValidator();
      validator.CssClass = "validator-error";
      validator.Display = ValidatorDisplay.Dynamic;
      validator.ControlToValidate = this.ID;
      validator.Text = "You've exceeded the maximum allowed length for this field";
      validator.ClientValidationFunction = "checkLength";
  
      this.Controls.Add(validator);
  
      base.OnInit(e);
  }
  </code></pre>