473,387 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Label versus Literal

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

Sep 22 '06 #1
4 1532
"shapper" <md*****@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
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...
Sep 22 '06 #2
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.

"shapper" <md*****@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
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

Sep 22 '06 #3
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.

Kevin Spencer wrote:
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.

"shapper" <md*****@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
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
Sep 22 '06 #4
I would agree with you! And I'm not at all certain that this is simply a
matter of opinion!

--
HTH,

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

A watched clock never boils.

"shapper" <md*****@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
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.

Kevin Spencer wrote:
>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.

"shapper" <md*****@gmail.comwrote in message
news:11**********************@k70g2000cwa.googleg roups.com...
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

Sep 23 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: SysSpider | last post by:
Hi again, This is my problem: when i try to compile the code that contains the function below, i get this: -- gcc:21: error: case label does not reduce to an integer constant gcc:24: error:...
1
by: NancyASAP | last post by:
I have a label on my ASP.NET form. It has a cssclass that includes a background color. I am dynamically putting text in this label. The text contains some embedded html (I want to display part...
6
by: Joe | last post by:
I know that the Literal control will not render a <span> tag so I can not format its text. Other than this, what is the difference betwen the Literal control and the LiteralControl Control? How...
2
by: David Thielen | last post by:
We have a status message we display that can be good news (in green) or bad news (in red). Is there a way to do this for a single literal or label? Or do we need to have two, one set to green and...
2
by: David Thielen | last post by:
Hi; I have some error messages I have to create (can't use the validators). I have done this using both labels and literals - is there any reason to prefer one over the other? Note: We are...
135
by: Xah Lee | last post by:
Tabs versus Spaces in Source Code Xah Lee, 2006-05-13 In coding a computer program, there's often the choices of tabs or spaces for code indentation. There is a large amount of confusion about...
3
by: ASP Developer | last post by:
I have a variety of pages that use a master page. For some reason when I attempt to copy any of the label text on the screen it seems to highlight most of the screen randomly and I can't simply...
6
by: versus | last post by:
Hi I have a table column that has multiple lines (\r\n) and html tags in it. I want to display it in a div and label that html tags can be seen and newlines should work. If i use div.innerHTML...
1
by: Brian Simmons | last post by:
I'll try to keep this short & sweet and hopefully get the direction I'm looking for. I'll drop a SqlDatasource onto a webform. Configure it to use a stored proc, perhaps have the parameters be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.