What is the use of the AssociatedControlID?

Tuesday, July 14, 2009


If you want to associate a control with Label, then you can give an access key to the label control and set the AssociatedControlID property of the Label to the control to which you want the label to associate. When you do so, upon clicking the AccessKey Focus will be set to the Associated Control.


Ex:
<form id="form1" runat="server">
<div>
<asp:Label ID="lblName" runat="server" AccessKey="N" AssociatedControlID="TextBox1"
Text="Name"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" AccessKey="B" OnClick="Button1_Click" /></div>
</form>



www.codecollege.NET

0 comments

Post a Comment

www.codecollege.NET

Blog Widget by LinkWithin