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

A

Alan Silver

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
 
C

Curt_C [MVP]

Alan said:
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
 
I

intrader

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
 
A

Alan Silver

Suppose I have a page that has several literal controls and I want to be
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.
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top