In asp.net I am using the label field in which I am keeping ID and AssociatedControlID same then its not throwing any exception
<asp:Label ID="Username" runat="server" AssociatedControlID="Username">Username:</asp:Label>
But when I am using ID and AssociatedControlID differently then I am getting an exception
<asp:Label ID="lblUsername" runat="server" AssociatedControlID="Username">Username:</asp:Label>
the exception I am getting is
Unable to find control with id ‘Username’ that is associated with the Label ‘lblUsername’
What might be the reason?
Usually you associate a label to another control like a
TextBox.Since you try to associate it to some control with id
Usernamein the second example I can guess that you don’t have another control with idUsername. That is why you’re getting the exception.