Sunday, August 17, 2014

Filled Under:
,

Label control in asp.net with example

Label control in asp.net with example

In this topic we are going to see how to use Label control in asp.net with example

The ASP.NET Framework includes two controls you can use to display text in a page: the Label control and the Literal control. Whereas the Literal control simply displays text, the Label control supports several additional formatting properties.

Using the Label Control :-

Whenever you need to modify the text displayed in a page dynamically, you can use the Label control. For example, the following example dynamically modifies the value of a Label control’s Text property to display the current time.

HtmlMark up:-


C#-code

Output-




Any string that you assign to the Label control’s Text property is displayed by the Label when the control is rendered. You can assign simple text to the Text property, or you can assign HTML content.

As an alternative to assigning text to the Text property, you can place the text between the Label control’s opening and closing tags. Any text that you place before the opening and closing tags is assigned to the Text property.


By default, a Label control renders its contents in an HTML <span> tag. Whatever value you assign to the Text property is rendered to the browser enclosed in a <span> tag.




0 comments:

Post a Comment