Label versus Literal

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

What control should I use when displaying some text? A Literal or a
Label?

Considerer I want to display some text and apply a CSS class to it.

I can do it in 2 ways:

MyLabel.CssClass = "MyClass"

MyLabel.Text = "My Text"

Or using a Literal

MyLiteral.Text = "<p class=""MyClass"">My Text</p>"

Which approach should I use?

I know Asp:Label is good for placing before a TextBox.

However in the situation I explained in this message I don't know which
one should I use.

Could someone, please, help me out with this?

Thanks,

Miguel
 
Could someone, please, help me out with this?

Try both and inspect the HTML that ASP.NET outputs...

I really don't think it will make much difference in the grand scheme of
things...
 
Good OOP hides complexity. Imagine you have 100 Labels on a page. Now,
imagine you have 100 LiteralControls on your page. Which is easier for you
to read and work on?

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

A watched clock never boils.
 
In my opinion, the Label. Because of CSS and SkinID.
I will be able to change everything in a moment.

But this is my opinion.
 
Back
Top