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!