Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2007, 04:04 PM
Authorized User
 
Join Date: Jul 2007
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Label vs Literal

It seems in some places in the book simple text (such as text next to a TextBox in a form) is represented as a Label while in other places simple text is represented as a Literal. Is there any logic in determining the proper control for text that ultimately serves no purpose other than textual? Also, if the text isn't needed pro grammatically, does it really make sense to put it in a control at all?

 
Old October 6th, 2007, 09:13 PM
Authorized User
 
Join Date: Jan 2007
Location: , , .
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by pinch
 It seems in some places in the book simple text (such as text next to a TextBox in a form) is represented as a Label while in other places simple text is represented as a Literal. Is there any logic in determining the proper control for text that ultimately serves no purpose other than textual? Also, if the text isn't needed pro grammatically, does it really make sense to put it in a control at all?
Sure, if you're never going to need to use a particular text string programmatically, I don't see a point in using them either. I agree with that.

But there is a difference between the two controls, when you do use them. If you need to provide css styling or anything like that, you'll need to use a Label. This is because when the page's markup is actually rendered, Labels wrap the text in a <span> tag with those styling/etc attributes, whereas Literals can display nothing but the text.

Just look at how much more intellisense you get with a Label compared to a Literal, and look at the markup you get in your browser. Hope that helps!

 
Old October 9th, 2007, 01:01 PM
Authorized User
 
Join Date: Jul 2007
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It does, thanks. :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
What's the use of braces in a string literal? aaaa0441 Pro PHP 7 January 20th, 2007 04:23 AM
What's the use of braces in a string literal? aaaa0441 Beginning PHP 4 January 14th, 2007 08:10 AM
Literal Control bilal589 ASP.NET 1.0 and 1.1 Basics 5 August 19th, 2006 01:42 PM
Using right() to return a literal value Somed00d Access 4 February 8th, 2006 02:56 PM
Object literal syntax shortt Javascript 4 May 28th, 2005 07:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.