Mega Code Archive

 
Categories / ASP.Net Tutorial / ASP Net Controls
 

Use of AssociatedControlID property on labels to bind a particular label to an input control

<%@ Page language="C#" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title>Label For</title> </head> <body>     <div id="pageContent">         <form runat="server" id="MainForm">             <asp:Label ID="Label1" runat="server" Text="This label has no associated control"></asp:Label>             <asp:TextBox ID="TextBox1" runat="server" />             <br />             <asp:Label ID="Label2" runat="server" Text="This label is associated with the textbox"                  AssociatedControlID="TextBox2"></asp:Label>             <asp:TextBox ID="TextBox2" runat="server" />         </form>     </div> </body> </html>