Label versus Literal

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
 
M

Mark Rae

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...
 
K

Kevin Spencer

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.
 
S

shapper

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top