asp.net.ph

Label.Text Property

System.Web.UI.WebControls Namespace   Label Class


Sets or retrieves the text displayed for a Label control.

Syntax


Inline <asp:label text = strtext ... >
Script Label.Text [ = strtext ]

Property Value


strtext String that specifies the text caption for the label.

The property is read/write with no default value.

Remarks

Use the Text property to specify or determine the content displayed in a Label control.

The text of a label control can contain HTML, such as an image tag.

In certain cases, as when labels are used within templated controls, the Text property is usually obtained dynamically from a data source.

Example

The following shows how you can programmatically set the Text property of a Label control at run time, based on user input.

void greetUser ( Object src, EventArgs e ) {
   greeting.Text = "Greetings, " + 
    ( ( userName.Text != "" ) ? userName.Text : "earthling" ) + 
      ", welcome to ASP.NET " +
      "<img src='/shared/wink.gif' width=15 height=15 border=0 alt=''>";
}
  C# VB

 Show me 

The following examples demonstrate how to dynamically bind the Text property of Label controls defined within templates.

DataList Editing Command Events Example
Run Sample | View Source
Using a DropDownList in an Editable DataList
Run Sample | View Source
See Also

Label Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 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 asp.net.ph