asp.net.ph

Skip Navigation Links

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



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

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