this article introduces the difference between literal control and label control in asp.net 2.0
[@more@]Label
The Label Web Server control is used to label other parts of the application. They are used to display text which the user can't change. To display text on a label we use the text property. The class hierarchy for this control is as follows:
Object
Control
WebControl
Label
A label control with BorderStyle property as solid and BorderColor property as blue is shown below.
I am Label
A Literal Web Server control doesn't have any visual appearance on a Web Form but is used to insert literal text into a Web Form. This control makes it possible to add HTML code directly in the code designer window without switching to design view and clicking the HTML button to edit the HTML. The class hierarchy for this control is as follows:
Object
Control
Literal
The notable property of this control is the text property which is the text that is inserted into the Web Form. A literal control with text "I am Literal" is displayed below.
I am Literal
Editing HTML with Literal Control
As mentioned above, we can use a literal control to edit the HTML directly in the code designer. The following line of code demonstrates that.
Literal1.Text = "I am Literal" |
To test the above line of code click the button below. The text "I am Literal" displayed beside the Button will be underlined and will be displayed in bold format. The difference is we added HTML code directly in the code designer window instead of switching and editing it in HTML view.
Live Code Demo
I am Literal
after render html Hello World
after render html Hello World
Addition:
* Label have property to apply style
* Label can be access via clientscript
** and many more
Hope this is Help!
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10771986/viewspace-968923/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10771986/viewspace-968923/