The Literal Control is similar to the Label Control as they both are used to display static text on a web page. The Literal Control is not inherited from WebControl namespace. The Literal Control doesn't provide substantial functionality but Literal text is programmable. It doesn't add any HTML elements to the web page. You cannot apply a style to a literal control. That makes it more powerful, you can even put a pure HTML contents into it.
When to user Literal Control? Literal control is one of the rarely used controls but it is very useful. Literal control is light weight control. The Literal Control is useful when you want to add text to the output of the page dynamically from the server. With that you can even programmatically manipulate the Literal text from the code behind. In short you can say: The Literal control is used to display text; that is, it renders static text on a Web page without adding additional HTML tags.
It passes content directly to the client browser unless you use the Mode property to encode the content. For more information, see Validation Server Controls. User posted I'm still confused sorry. If i wanted to bring back something from the database, like First Name for instance, i'm setting it to a label. If i'm using text, not from a database, i'm using a label. Besides, datagrids etc I usually use a label to display db or non-db text.
Is this wrong? Very confusing User posted I usually use a literal control when i want to display the actual HTML code some typed in be from a textbox or a DB , and i use the label control when i want to display the code with the HTML formatting applied. User posted There is nothig wrong with it to use Label to display text values or values conerted to text strings from DB fields.
User posted Outstanding description SomeNewKid2. Thanks Guys. User posted It is better to use literal control rather than label control. Wednesday, May 14, AM. User posted The asp : Label control is used to label other elements on the page similar to an html label. In fact , when you set the AssociatedControl property , the asp : Label produces an html label as its output. An asp : Literal control doesn 't have any visual appearance on a page, but can be used to insert literal text.
As such, the asp:Literal control can be used to insert html code directly in to the page. You should use an asp:Label to give meaning to all form elements, eg: Textbox, Checkbox etc. You could use an asp:Literal when you need to insert a value, or some html into your page. Monday, June 2, AM. User posted One more difference I've just noticed: asp:Literal does not have a "cssclass" property asp:Label does have a "cssclass" property Tuesday, July 22, AM.
User posted Comparing the Literal Control to Other Options The Literal control represents one of several options for adding content to a page. Monday, May 4, AM. How to redirect a page in asp. How to register custom server control on ASP. NET page? How do you validate Input data in Asp. What's the difference between ViewData and ViewBag? Difference between Response. Redirect and Server. Transfer What is the function of the CustomValidator control?
Define RequiredFieldValidator? Difference between custom control and user control What are the major events in Global. What is Event Bubbling in asp. What is Delay signing? What is the difference between in-proc and out-of-proc? A potentially dangerous Request.
Form value was detected from the client.
0コメント