Label control is used to show the text on the web web page. This label manipulate is used together with different controls like textboxes. It’s very common wherein the label is used with a textbox. Labels typically assist the user to offer the facts inside the text bins by the written indications. Labels are server-facet controls. We can show the text in label control via placing the text via textual content property. By way of changing its label manipulate residences, we can exchange the label controls style or look and sense. So we can personalize it as in step with our necessities.
< asp:LabelID="Label1" runat="server" Text="Label" ></asp:Label>
Let us see how exactly the ASP.NET label works.
Public partial class _Default : System.Web.UI.Page
Protected void page_Load(object sender, EventArgs e)
Label1.Test=” Welcome to EduCba”;
Label Control has its properties, which will be used to make it more enhanced.
Below are the examples of ASP.NET Label:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebControls.aspx.cs"
<form id="form1" runat="server">
<h4>Fill the Employee ID in below text box:</h4>
<asp:Label ID="Label1" runat="server" Text="Employee ID"></asp:Label></td>
<asp:TextBox ID="TextBox1" runat="server" CssClass="auto-style2"></asp:TextBox></td>
<asp:Label ID="Label2" runat="server" Text="Upload a File"></asp:Label></td>
<asp:FileUpload ID="FileUpload1" runat="server" /></td>
Explanation of the above code: We can see in the above code that asp gives its tag to use it as a label.<asp:Label ID =Label1> determines its id. Run at is always set to be “Server” as this is server-side control. We have added 2 labels here having the text as Employee ID and upload file. We can use this Label Control Method.
There is some Label control given below:
AutoSizeChanged: When the value of AutoSize Property changes this occurs.
Click: When we click the Label Control, this is used.
DoubleClick: When label control is double-clicked this occurs.
GotFocus: When label control receives focus this occurs.
Leave: When input controls leave, the focus of the control label comes under the picture.
Subscribe to get latest updates