The next code shows how you can attach an asp:Label control with the asp:TextBox. In this case when the user clicks the Label the application will focus on the TextBox.

C# 8.0 and .NET Core 3.0 – Modern Cross-Platform Development: Build applications with C#, .NET Core, Entity Framework Core, ASP.NET Core, and ML.NET using Visual Studio Code, 4th Edition
ASP.NET Core 3 and Angular 9: Full stack web development with .NET Core 3.1 and Angular 9, 3rd Edition
C# in Depth, 4th Edition



<%@ Page Language=”vb” AutoEventWireup=”false” CodeBehind=”TestAssociate.aspx.vb” Inherits=”TextChange.TestAssociate” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”>

<html xmlns=””>

<head runat=”server”>

<title>Associate a Label with a TextBox</title>



<form id=”form1″ runat=”server”>


<asp:Label ID=”LabelEMail” runat=”server” Text=”E-Mail: ” AssociatedControlID=”TextEMail”></asp:Label>

<asp:TextBox ID=”TextEMail” runat=”server”></asp:TextBox>





You can associate the Label to the TextBox control by specifying the Label property AssociateControlID to the TextBox’s ID. Clicking on the Label control focuses the TextBox.