Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Web Server Controls
Standard Controls
 How to: Use Label Web Server Contro...
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
ASP.NET 
How to: Use Label Web Server Controls as Captions 

You can use the Label Web server control to act as an active caption in front of another Web server control, such as a TextBox control. The Label control cannot receive the user input focus. However, by associating the Label control with another control, users can navigate to the associated control by simultaneously pressing the ALT key with an access key that you define for the Label control.

To use a Label Web server control as a caption

  1. Set the Label control's AssociatedControlID property to the ID of the control for which you want the Label control to be the caption.

  2. Set the Label control's AccessKey property to a single letter or number to define an access key

    NoteNote

    If you associate the Label control with a button, when users simultaneously press the ALT key with the access key for the Label control, the button is clicked.

  3. Optionally, set the Text property of the Label control to display an underlined character that indicates the access key.

    The following example shows how to use a Label control as a caption for a TextBox control. When the page renders, users will be able to press ALT+N to navigate to the text box. The letter N in the Label is underlined.

    <asp:Label 
        AccessKey="N"
        AssociatedControlID="TextBox1" 
        ID="Label1" 
        runat="server"
        Text="<u>N</u>ame:">
    </asp:Label>
    &nbsp;
    <asp:TextBox ID="TextBox1" runat="server" />

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker