programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Thursday, July 31, 2014

Label Control

Label Control Definition:

The Label control is web control used to display data on a web page in development. The text is programmable Dynamic or static. Basically it is use for display message. Label Declare : 

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

ID is use to Access control for C#programming Language.

Use of Label: label control use to show data, in this we can display static data, fix data by property or bind data (Text) by C# code. We can also access label control by JavaScript on page.

Access Label using JavaScript:

Var lbl=document.getbyID(‘<%ControlID%>);

label control Properties :

Basically there are two impotent properties runat and text
Runat:  specify this control Execute on server site.
Text:  specify what we can display in this control.

Standard Properties of label Asp control:

BackColor of label, BorderColor of label, BorderStyle of label, BorderWidth of label, CssClass of label, Enabled of label, Font of label, EnableTheming of label, ForeColor of label, Height of label, IsEnabled of label, SkinID of label, Style of label, TabIndex of label, ToolTip of label, Width of label.

Label Control Standard Properties:

AppRelativeTemplateSourceDirectory of label, BindingContainer of label, ClientID of label of label, Controls of label, EnableTheming of label, EnableViewState of label, ID of control, NamingContainer of control, TemplateControl, TemplateSourceDirectory, UniqueID of control, Visible.

Example of Label control:

Label: In the Label control Example we take five labels with different-2 type. With different properties.
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>   
        <br />

        <asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Size="X-Large"
        <br />

        <asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Size="Xx-Large"
            ForeColor="Red" Text="Label"></asp:Label>
        <br />

        <asp:Label ID="Label4" runat="server" BorderColor="#999999"
            BorderStyle="Groove" Font-Bold="True" Font-Size="XX-Large" Text="Label"
       <br />

        <asp:Label ID="Label5" runat="server" BackColor="#666666" BorderColor="#993300"
            BorderWidth="2px" Font-Bold="True" Font-Size="XX-Large" Height="75px"
            Text="Label" Width="289px"></asp:Label>
        <br />
    </div> label control label control

Asp label in Programming with example

In this Label Example we take one button control and one Label. After Execute click event then Message will be display that "Button clicked".

Label code for aspx page :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Label_Control.aspx.cs" Inherits="Label_Control" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
    <div><h1>Label Example with button </h1>   
        <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />   


Label control code for aspx.cs  page :

using System;

using System.Collections.Generic;

using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Label_Control : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)


    protected void Button1_Click(object sender, EventArgs e)
        Label1.Text = "Button clicked";

Reference :