By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,853 Members | 2,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,853 IT Pros & Developers. It's quick & easy.

Literal control doesn't have CssClass property?

P: n/a
All,

Today I was playing with Literal control. Basically it is more or less like
the Label control with this difference that Literal control is something
like "lightweight" text container (that is it doesn't have any server side
functionality like responding to events, etc.). Now the thing that prevents
me from using it, is the fact that I can't assign CSS class to it. Do you
guys know why is that, why I can't set the CSS class directly to this
control? If can't do this, I have to go with Label control only for this
difference, but this will make my server side page rendering heavier.

Regards,
George Jordanov Ivanov
Mar 30 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
IIRC it doess't assign a CSS class because it doesn't write any tags
out. It's not much of a container, it's just a placeholder Where do you
want the CSS class to be written to?

If you need to dynamically set the CSS of a span, you can always run
that at server and declare it in your code as an HtmlContainerControl.

Mar 30 '06 #2

P: n/a
For applying a css class, the output of the literal control must have a
wrapping element like <span>bla bla</span>. As the purpose of the
Literal control is to do not supply any output but what the user puts in
the Text property, it cannot be relied upon that it will contain a valid
wrapping element.

btw. Using labels does not make the rendering time of your asp.net page
significant longer.

--
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com

"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx
Mar 30 '06 #3

P: n/a
The whole point of the Literal controls is that it outputs static text, as
opposed to an html control. You can't assign style to it in the same way as
you can't attach style to static text in html. If you care so much about
having a lite server side, write your page in html and just add runat=server
to the controls that you want to see on server.

Eliyahu

"George Jordanov Ivanov" <ge***********@newsgroups.nospam> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...
All,

Today I was playing with Literal control. Basically it is more or less
like the Label control with this difference that Literal control is
something like "lightweight" text container (that is it doesn't have any
server side functionality like responding to events, etc.). Now the thing
that prevents me from using it, is the fact that I can't assign CSS class
to it. Do you guys know why is that, why I can't set the CSS class
directly to this control? If can't do this, I have to go with Label
control only for this difference, but this will make my server side page
rendering heavier.

Regards,
George Jordanov Ivanov

Mar 30 '06 #4

P: n/a
The literal control, literally displays what is stored in the text property.
Therefore if you want to apply css styles to the text you have to set the
text property to the HTML that you would use in a static web page to achive
the style you want. The literal control is for doing what it's name says,
displaying literal text with no filtering or modification at all.

"George Jordanov Ivanov" wrote:
All,

Today I was playing with Literal control. Basically it is more or less like
the Label control with this difference that Literal control is something
like "lightweight" text container (that is it doesn't have any server side
functionality like responding to events, etc.). Now the thing that prevents
me from using it, is the fact that I can't assign CSS class to it. Do you
guys know why is that, why I can't set the CSS class directly to this
control? If can't do this, I have to go with Label control only for this
difference, but this will make my server side page rendering heavier.

Regards,
George Jordanov Ivanov

Mar 30 '06 #5

P: n/a
Thank you all for the thorough answer - you rock guys! :o)

George Jordanov Ivanov
www.givanov.net/blog
"George Jordanov Ivanov" <ge***********@newsgroups.nospam> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...
All,

Today I was playing with Literal control. Basically it is more or less
like the Label control with this difference that Literal control is
something like "lightweight" text container (that is it doesn't have any
server side functionality like responding to events, etc.). Now the thing
that prevents me from using it, is the fact that I can't assign CSS class
to it. Do you guys know why is that, why I can't set the CSS class
directly to this control? If can't do this, I have to go with Label
control only for this difference, but this will make my server side page
rendering heavier.

Regards,
George Jordanov Ivanov

Mar 30 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.