title: How to make a server control work with asp:Label's AssociatedControlID property
body: <p>When you set the <code>AssociatedControlID</code> property on a Label control, it renders a <code>&lt;label&gt;</code> HTML tag with its <code>for</code> attribute set to the target control's ClientID:</p>
  
  <pre><code>&lt;label id="Label" for="TextBox"&gt;Dat TextBox&lt;/label&gt;
  &lt;input id="TextBox" name="TextBox" type="text"&gt;
  </code></pre>
  
  <p>I've made a server control that has a TextBox inside it and I would like for the label to render its <code>for</code> attribute to my control's interior TextBox.  My first thought was to point directly to my server control:</p>
  
  <pre><code>&lt;asp:Label ID="AwesomeLabel" runat="server" AssociatedControlID="AwesomeControl"&gt;
      Check out my awesome control!&lt;/asp:Label&gt;
  &lt;custom:MyControl ID="AwesomeControl" runat="Server" /&gt;
  </code></pre>
  
  <p>But that makes the <code>for</code> attribute point to the <code>&lt;span&gt;</code> that is rendered around the server control's contents:</p>
  
  <pre><code>&lt;label id="AwesomeLabel" for="AwesomeControl"&gt;Check out my awesome control!&lt;/label&gt;
  &lt;span id="AwesomeControl"&gt;
      &lt;input name="AwesomeControl$ct123" type="text"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>It seems as though <code>AssociatedControlID</code> sets the <code>for</code> attribute by simply getting the target control's ClientID:</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.label.associatedcontrolid.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.label.associatedcontrolid.aspx</a></p>
  
  <p>I don't want to go into the page's .aspx.cs to set this programmatically, because this server control is used frequently and I'd like its implementation to be as quick as possible.  </p>
  
  <p>Is there any other way to make Label tags render their <code>for</code> attributes to my server control's interior TextBox, either in the .aspx markup or from my server control's code?</p>