Literal control - why?

Discussion in 'ASP .Net' started by VB Programmer, Jun 10, 2004.

  1. What's the real advantage to using a literal control over a simple label?
    What are the pros/cons/typical usages for the literal control?

    Thanks.
     
    VB Programmer, Jun 10, 2004
    #1
    1. Advertising

  2. A label renders a <span> tag. It allows you to programmatically change the
    display characteristics of some text you want to display. A LiteralControl
    renders exactly whatever static HTML you want it to. There is no general
    advantage of using one over the other. One may be more useful than another
    in certain circumstances. For example, if you want to display static text,
    and make no programmatic changes to it, you might want to use a
    LiteralControl.

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "VB Programmer" <> wrote in message
    news:ehe$...
    > What's the real advantage to using a literal control over a simple label?
    > What are the pros/cons/typical usages for the literal control?
    >
    > Thanks.
    >
    >
     
    Kevin Spencer, Jun 10, 2004
    #2
    1. Advertising

  3. VB Programmer

    Raterus Guest

    I think they only real difference is that it inherits from Control, not WebControl, so you can't apply a style to the text. It probably would be a bit faster to render in that aspect as well.

    http://msdn.microsoft.com/library/d...rfsystemwebuiwebcontrolsliteralclasstopic.asp

    And you can't do this with a label control, in one line..

    someControl.controls.add(new LiteralControl("any text I want rendered"))

    "VB Programmer" <> wrote in message news:ehe$...
    > What's the real advantage to using a literal control over a simple label?
    > What are the pros/cons/typical usages for the literal control?
    >
    > Thanks.
    >
    >
     
    Raterus, Jun 10, 2004
    #3
  4. Hi,


    Usually I use a Literal to inject Javascript code to the client.

    Cheers,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation


    "VB Programmer" <> wrote in message
    news:ehe$...
    > What's the real advantage to using a literal control over a simple label?
    > What are the pros/cons/typical usages for the literal control?
    >
    > Thanks.
    >
    >
     
    Ignacio Machin \( .NET/ C# MVP \), Jun 10, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wooks
    Replies:
    0
    Views:
    629
    wooks
    Jul 31, 2003
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    904
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,970
    Smokey Grindel
    Dec 2, 2006
  4. Replies:
    0
    Views:
    315
  5. Anonieko Ramos

    What's wrong with rpc-literal? Why use doc-literal?

    Anonieko Ramos, Sep 27, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    380
    Anonieko Ramos
    Sep 27, 2004
Loading...

Share This Page