aspxtreme

Label Control Syntax

ASP.NET Syntax   ASP.NET Syntax for Web Controls


Displays static text on the Web Forms page and allows you to manipulate it programmatically.

Declarative Syntax

NOTE: The content of an <asp:Label> control can be defined within its opening tag. In this case, you can close the start tag with a trailing slash /> instead of using a separate end tag.

For information on the individual members of this class, see Label in the class library.

Remarks

The Label control renders text in a set location on a Web Forms page. Unlike static text, you can customize the displayed text by setting the Text property.

Syntax Example

The below code snippet demonstrates how to use a Label control to display the coordinates on an image where the user clicks.

<script language="C#" runat="server">

   void getImageCoords ( object Source, ImageClickEventArgs e ) {
      msgLabel.Text = "You clicked the ImageButton control at the " +
         coordinates: ( " + e.X.ToString ( ) + ", " +
         e.Y.ToString ( ) + " ) ";
   }

</script>
  C# VB
<form runat="server">

   <asp:ImageButton id="imagebutton1" runat="server"
      AlternateText = "ImageButton 1"
      ImageAlign = "left"
      ImageUrl = "images/pict.jpg"
      onClick = "getImageCoords" />

   <p><asp:Label id="msgLabel" runat="server" />

</form>
See Also

Label Class   Label Web Server Control



Books and more ...


Suggested Reading

Need a break ?



Previous page Back to top Next page

Check out related books at Amazon

© 2000-2008 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support aspxtreme