How to use Label Control in ASP.NET

How to use Label Control in ASP.NET

0 339
what is label control and how to use in

How to use Label Control in ASP.NET

Label in is a very simple control. Label Control is a non clickable control that means we cannot click on it for any response.Label Controls are used to show any information and it can be changed programmatically. Label control can be used with checkbox, radiobutton, button or any other control for notation purpose. In this article i will describe that How to use Label Control in ASP.NET.  To use Label Control in your program follow these steps:-

  1. Click on Toolbox List visible in your framework.
  2. Drag Label control in to the web form. You may also double click on it to insert in your web form
  3. Now you may see following code line in the source page of your web form.

In above coding asp: Label shows about the control that it is a Label control. ID=”Label1” shows that the Unique Identity name of this control is Label1. You may change it with your desired name. If the Label is related to marks of a student in any exam then you may put the name of this ID just like “StudentMarks” or “SMarks” etc. next attribute is runat=”Server” which means that this control will be execute on Server. The next field is Text=”Label”, here you may write the text which you want to show on your webpage. For example we want to show the text “Marks in Maths = 75”. So in this way the above text will be look like as below:-


This is the basic concept of Label Control. Now if you are using Visual Studio 2008 then you may see Split option in the bottom of your web form page in VS (Visual Studio) Framework. Split option is only available in VS 2008 or higher version. In VS 2005 this option is not available. Now just right click on the Label control in Design mode and click on properties. Now you may see more options so that you can customize Label control in your way. For example you may change ForeColor, background color, width, height and text value etc. Visible control is used to show or hide the control. If it is set to True then control will be visible else invisible.

Run the Program

Now you may run the program. To run the program there are 2 ways. First way is that, Just click on Build menu and click on build solution. Short cut key is F6. The second ways is that just click on solution explorer in the VS Framework and right click on the web form you want to run, and then click on “view in browser” drop down option.

Here is another instance of Label control with different attributes.

Just run this coding and understand the logic. Thanks a lot to read this article. Have a happy coding….





Leave a Reply