The AssociatedControlID property of the Label web control
This blog has moved to DotNetSlackers, please update your links and post comments there.
In ASP.NET 2.0 the Label web control exposes a new property, AssociatedControlID, which takes the ID of another control in the page, that is, a TextBox or another input control.
When the property is set, the rendering of the Label switches from a simple <span> tag to a <label> tag, whose for attribute assumes the client-side ID of the associated control as the value.
A sample to clear things up
<asp:label ID="Label1" runat="server" Text="Label" />
<asp:TextBox ID="TextBox1" runat="server" />
becomes:
<span id="Label1">Label</span>
<input name="TextBox1" id="TextBox1" type="Text" />
While
<asp:label ID="Label1" AssociatedControlID="TextBox1" runat="server" Text="Label" />
<asp:TextBox ID="TextBox1" runat="server" />
becomes:
<label for="TextBox1" id="Label1">Label</label>
<input name="TextBox1" id="TextBox1" type="Text" />
The difference
The difference is an accessibility feature. Setting the AssociatedControlID property any click on the Label extends to the associated control. In case of an associated TextBox the effect is that when clicking on the Label the TextBox gains focus.