Skip to main content

Add AssosiatedControlID Attribute (ASP.NET)

Adds the AssociatedControlID attribute to the current <asb:Label> tag.

#Purpose

  • Use this code provider to specify the control on which focus should be set when the <asb:Label> is clicked.

#Availability

Available from the context menu or via shortcuts:

  • when the cursor is anywhere in an <asb:Label> tag.

#Example

<form runat="server" enableviewstate="true" action="Default.aspx">
    <asp:button id="button4" EnableViewState="true" runat="server"></asp:button>
    <asp:textbox id="textbox1" enableviewstate="true" runat="server"></asp:textBox>
    <asp:label id="lbl2" text="Test" enableviewstate="false" runat="server">
    </asp:label>
</form>

Result:

<form runat="server" enableviewstate="true" action="Default.aspx">
    <asp:button id="button4" EnableViewState="true" runat="server"></asp:button>
    <asp:textbox id="textbox1" enableviewstate="true" runat="server"></asp:textBox>
    <asp:label id="lbl2" text="Test" enableviewstate="false" runat="server" associatedcontrolid="button4">
    </asp:label>
</form>