The difference between literal and label.

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

Literal

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/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值