How to: Add Label Web Server Controls to a Web Forms Page (Visual Studio)
You can addWeb server controls as self-standing controls on your ASP.NET Web page. You can also make Label controls child controls of other controls, such as using them in Web server control templates. For details, see .
If you want to display static text, you can present it by using HTML — you do not need a Label control. Use a Label control only when you need to change the contents or appearance of text programmatically.
To add a Label Web server control to a Web Forms page
From the Standard tab of the Toolbox, drag a Label control onto the page.
In the Appearance category of the Properties window, set the control'sproperty to the text to display. You can include HTML formatting in the property; for example, you can format an individual word in the text as bold by placing a <b> tag around it in the Text property.
The following example shows how you can set the text of a Label control at run time. The method displays in the Label control whatever the user has typed into thecontrol named TextBox1.
Be careful when using the Label control to display strings that come from an untrusted source. They can include potentially malicious client script. For details, see.
Protected Sub Button1_Click(ByVal sender as Object, _ ByVal e as EventArgs) Label1.Text = Server.HtmlEncode(TextBox1.Text) End Sub