Asp.net Label control












asp:Label control

In a perfect world Label control is utilized to put a static, non interactive (can't fire onclick occasion) bit of content on the page. When it is rendered on the page, it is actualized through <span></span> HTML tag. Its properties like BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height and so on are actualized through style properites of <span>. You can set its Text property either by setting Text properties in the .aspx page or from server side page. (different properties can likewise be set from the two pages)
Following are few properties of the Label that are very useful.
EnableViewStatetrue/false. If false ViewState will not be maintained.
Visibletrue/false. If false control will not be rendered to the page

Example - 

 // Label control code
                        <asp:Label ID="Label2" runat="server" BackColor="Coral"
                        ForeColor="blue" BorderColor="ActiveBorder"
                        BorderStyle="dashed" BorderWidth="1" Height="20"
                        Text="Example of Label Control" Width="200"
                        ></asp:Label>
                     
                        // Rendered HTML code of the Label
                        <span id="ctl00_PlaceHolderForContents_Label1"
                        style="display:inline-block;color:Blue;
                        background-color:Coral;
                        border-color:activeborder;border-width:1px;
                        border-style:Dashed;
                        height:20px;width:200px;">
                        Example of Label Control</span>
                 
                        // Fires when Button is clicked
                        protected void ChangeLabelText(object sender, EventArgs e)
                        {
                            Label1.Text = TextBox1.Text;
                        }
Share on Google Plus

About It E Research

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment