Is it possible to set the Text property of more than one literal in one go?

Discussion in 'ASP .Net' started by Alan Silver, Jun 29, 2005.

  1. Alan Silver

    Alan Silver Guest

    Hello,

    Suppose I have a page that has several literal controls and I want to be
    able to set the Text property of these controls all to the same value.
    Is there a simple way of doing this?

    The example in hand is where I want to set both the <title> tag and a
    <h1> tag on the body of the page to show the name of the product being
    displayed. I know I can do this in two lines, but I was wondering if
    there is a way doing it in one go, so if I need to use the product name
    elsewhere, I can just add another control and not need to remember to go
    back and add an extra line to set the Text.

    Any ideas? TIA

    --
    Alan Silver
    (anything added below this line is nothing to do with me)
     
    Alan Silver, Jun 29, 2005
    #1
    1. Advertising

  2. Alan Silver

    Curt_C [MVP] Guest

    Re: Is it possible to set the Text property of more than one literalin one go?

    Alan Silver wrote:
    > Hello,
    >
    > Suppose I have a page that has several literal controls and I want to be
    > able to set the Text property of these controls all to the same value.
    > Is there a simple way of doing this?
    >
    > The example in hand is where I want to set both the <title> tag and a
    > <h1> tag on the body of the page to show the name of the product being
    > displayed. I know I can do this in two lines, but I was wondering if
    > there is a way doing it in one go, so if I need to use the product name
    > elsewhere, I can just add another control and not need to remember to go
    > back and add an extra line to set the Text.
    >
    > Any ideas? TIA
    >


    use a variable to hold it... but in the end its still multiple lines

    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com
     
    Curt_C [MVP], Jun 29, 2005
    #2
    1. Advertising

  3. Alan Silver

    Alan Silver Guest

    >> Hello,
    >> Suppose I have a page that has several literal controls and I want
    >>to be able to set the Text property of these controls all to the same
    >>value. Is there a simple way of doing this?
    >> The example in hand is where I want to set both the <title> tag and
    >>a <h1> tag on the body of the page to show the name of the product
    >>being displayed. I know I can do this in two lines, but I was
    >>wondering if there is a way doing it in one go, so if I need to use
    >>the product name elsewhere, I can just add another control and not
    >>need to remember to go back and add an extra line to set the Text.
    >> Any ideas? TIA

    >
    >use a variable to hold it... but in the end its still multiple lines


    OK thanks, it was just an idea.

    --
    Alan Silver
    (anything added below this line is nothing to do with me)
     
    Alan Silver, Jun 29, 2005
    #3
  4. Alan Silver

    intrader Guest

    On Wed, 29 Jun 2005 18:59:09 +0100, Alan Silver wrote:

    > Hello,
    >
    > Suppose I have a page that has several literal controls and I want to be
    > able to set the Text property of these controls all to the same value.
    > Is there a simple way of doing this?
    >
    > The example in hand is where I want to set both the <title> tag and a
    > <h1> tag on the body of the page to show the name of the product being
    > displayed. I know I can do this in two lines, but I was wondering if
    > there is a way doing it in one go, so if I need to use the product name
    > elsewhere, I can just add another control and not need to remember to go
    > back and add an extra line to set the Text.
    >
    > Any ideas? TIA

    What about overriding the Render method, catching the output of the base
    class, then using string replace to change the stuff.

    Or
    Use <%=something%> at the appropriate places and give a values to
    something
     
    intrader, Jul 1, 2005
    #4
  5. Alan Silver

    Alan Silver Guest

    >> Suppose I have a page that has several literal controls and I want to be
    >> able to set the Text property of these controls all to the same value.
    >> Is there a simple way of doing this?
    >>
    >> The example in hand is where I want to set both the <title> tag and a
    >> <h1> tag on the body of the page to show the name of the product being
    >> displayed. I know I can do this in two lines, but I was wondering if
    >> there is a way doing it in one go, so if I need to use the product name
    >> elsewhere, I can just add another control and not need to remember to go
    >> back and add an extra line to set the Text.
    >>
    >> Any ideas? TIA

    >What about overriding the Render method, catching the output of the base
    >class, then using string replace to change the stuff.


    Ulp, not sure I'd know how to do that!! It sounds a bit beyond my
    limited capabilities at the moment.

    Where would I find more info about how this is done? Maybe I'll look and
    see.

    >Or
    >Use <%=something%> at the appropriate places and give a values to
    >something


    Funny, as an ex-Classic ASP programmer, I've studiously avoided using
    <%=%> as it sounds like the "old" way of doing things. It never even
    crossed my mind to do it that way!! I guess I'm trying to get my head
    into the OOP way of looking at web pages, and this doesn't really fit
    with that.


    Thanks for the reply.

    --
    Alan Silver
    (anything added below this line is nothing to do with me)
     
    Alan Silver, Jul 3, 2005
    #5
    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. Mark Rae
    Replies:
    5
    Views:
    5,374
    Mark Rae
    Jan 12, 2007
  2. lovecreatesbeauty
    Replies:
    17
    Views:
    663
    Keith Thompson
    Jun 16, 2006
  3. Merciadri Luca
    Replies:
    4
    Views:
    834
  4. Steven D'Aprano
    Replies:
    0
    Views:
    116
    Steven D'Aprano
    Dec 23, 2013
  5. Replies:
    3
    Views:
    98
    Gary Herron
    Dec 23, 2013
Loading...

Share This Page