literal or label for error message

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 localizing the error messages in resource files.
 
The Literal control is only a reserved place in memory to add to its controls
collection any other control. The text that saved in the Text property of
the Literal will rendered as is (i.e. without any enclosed HTML tag). The
Label control on the other hand renders a specific HTML object tag named
<span>. This difference means that you cannot style a literal control unless
you style its contents but the label control has attributes such as CssClass
to allow you to style the <span> tag.
 
The Literal control is only a reserved place in memory to add to its controls
collection any other control. The text that is saved in the Text property of
the Literal will be rendered as is (i.e. without any enclosing HTML tag).
The Label control on the other hand renders a specific HTML object tag named
<span>. This difference means that you cannot style a literal control unless
you style its contents but the label control has attributes such as CssClass
to allow you to style the <span> tag. For a reference you might read this
article from the MSDN:

http://msdn2.microsoft.com/en-us/library(d=robot)/sz4949ks.aspx
 

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

Back
Top