VB.net Tutorials with Examples

VB.Net Projects

VB.Net Project 1

adplus-dvertising
Label Control in ASP.NET
Previous Home Next

It is used to provide the static information on the webform. Common properties for all the server side controls

PropertiesDescription
Id Used to specify the unique identifier for the control placed on the webform.
runat="Server" all control run on sever
Text It is used to set or get the value from the server side control..

The attribute is used to uniquely identify the <asp:label> control so you can refer to it in your ASP.NET code. The runat="server" attribute tells the server to process the control and generate HTML code to be sent to the client.

The class hierarchy for this control is as follows

  1. Object
  2. Control
  3. Web Control
  4. Label

Syntax of Label Control

<asp: Label ID="Label1" runat="server" Text="This is a label control">
</asp: Label>

Simple Example of Lebel Control

Protected Sub Button1_Click(ByVal sender As Object, 
ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = "Hi I AM Label control"
End Sub

Click On Button

How To Write Line Break In ASP.NET Label Control

To write text in lines in standard ASP.NET label control you need to use HTML tag <br />. This is example label control that contains text in Four Lines lines:

<asp:Label ID="Label1" runat="server"
Text="This is Aditya<br />This is kamal<br /> This is Anil<br/> This is Ashish">
</asp:Label>
Previous Home Next