TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

ASP.Net Label

ASP.Net Label with asp.net tutorial, asp.net introduction, features, project, example, server controls, labels, textbox, button, hyperlink, radiobutton, calender, checkbox, fileupload, events handling, authentication, webforms model binding, html server control, compare validdator, range validator, validation summary, mvc introduction, mvc project, view, validation, entity framework, authentication etc.

<< Back to ASP

ASP.NET Web Forms Label

This control is used to display textual information on the web forms. It is mainly used to create caption for the other controls like: textbox.

To create label either we can write code or use the drag and drop facility of visual studio 2017.

This is server side control, asp provides own tag to create label. The example is given below.

< asp:LabelID="Label1" runat="server" Text="Label" ></asp:Label>

This control has its own properties that are tabled below.

Property Description
AccessKey It is used to set keyboard shortcut for the label.
TabIndex The tab order of the control.
BackColor It is used to set background color of the label.
BorderColor It is used to set border color of the label.
BorderWidth It is used to set width of border of the label.
Font It is used to set font for the label text.
ForeColor It is used to set color of the label text.
Text It is used to set text to be shown for the label.
ToolTip It displays the text when mouse is over the label.
Visible To set visibility of control on the form.
Height It is used to set height of the control.
Width It is used to set width of the control.

Example

// WebControls.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebControls.aspx.cs" 
Inherits="WebFormsControlls.WebControls" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
        .auto-style2 {
            margin-left: 0px;
        }
        .auto-style3 {
            width: 121px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
           <h4>Provide the Following Details:</h4>
            <table class="auto-style1">
                <tr>
                    <td class="auto-style3">
                        <asp:Label ID="Label1" runat="server" Text="User Name"></asp:Label></td>
                    <td>
                        <asp:TextBox ID="TextBox1" runat="server" CssClass="auto-style2"></asp:TextBox></td>
                </tr>
                <tr>
                    <td class="auto-style3">
                        <asp:Label ID="Label2" runat="server" Text="Upload a File"></asp:Label></td>
                    <td>
                        <asp:FileUpload ID="FileUpload1" runat="server" /></td>
                </tr>
            </table>        
        </div>
    </form>
</body>
</html>

This is a property window of label control.

ASP Label 1

Output:

Here, we have used label control with two different controls. It produces the following output.

ASP Label 2
Next TopicASP.NET TextBox




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf