title: Custom Control referenced by 'RequiredFieldValidator' cannot be validated
body: <p><strong>Question:</strong> How do I correctly extend a custom control to work with the RequiredFieldValidator? I've read <a href="http://support.microsoft.com/kb/310145/en-us" rel="nofollow">this</a>, but trying to implement it didn't solve the problem for me.
  This is what I've come up with so far:</p>
  
  <pre><code> &lt;%@ Register src="DynamicGenerator/Controls/ReferenceControl.ascx" tagname="ReferenceControl" tagprefix="uc1" %&gt;
      &lt;uc1:ReferenceControl ID="SelectAgreement" runat="server" /&gt;
      &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator" ControlToValidate="SelectAgreement" runat="server" ErrorMessage="Select an agreement!"&gt;&lt;/asp:RequiredFieldValidator&gt;
  </code></pre>
  
  <p>Code behind:</p>
  
  <pre><code>[ValidationProperty("ConceptDefinitionId")]
  public partial class ReferenceSelector : System.Web.UI.UserControl, IReference
  {
     //lots of other stuff
   public string ConceptDefinitionId
          {
              get { return ReferenceControl.ConceptDefinitionId ?? ""; }
              set { ReferenceControl.ConceptDefinitionId = value; }
          }
  }
  </code></pre>
  
  <p>Loading this page gives me the following error: </p>
  
  <p>Control 'SelectAgreement' referenced by the ControlToValidate property of 'RequiredFieldValidator' cannot be validated.</p>
  
  <p>stacktrace:</p>
  
  <pre><code>[HttpException (0x80004005): Control 'SelectAgreement' referenced by the ControlToValidate property of 'RequiredFieldValidator' cannot be validated.]
     System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(String name, String propertyName) +8739685
     System.Web.UI.WebControls.BaseValidator.ControlPropertiesValid() +40
     System.Web.UI.WebControls.BaseValidator.get_PropertiesValid() +21
     System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e) +27
     System.Web.UI.Control.PreRenderRecursiveInternal() +80
     System.Web.UI.Control.PreRenderRecursiveInternal() +171
     System.Web.UI.Control.PreRenderRecursiveInternal() +171
     System.Web.UI.Control.PreRenderRecursiveInternal() +171
     System.Web.UI.Control.PreRenderRecursiveInternal() +171
     System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
  </code></pre>