Saturday, March 24, 2012

This should be easy

Hi

I want to take a variable I have read from a database and place it in
<h1></h1tags on the web page. What's the best/easiest way to do this?

I don't want to use an asp:label because this is rendered as a <span>.

Thanks in advance

JohnJohn Haycock wrote:

Quote:

Originally Posted by

Hi
>
I want to take a variable I have read from a database and place it in
<h1></h1tags on the web page. What's the best/easiest way to do this?
>
I don't want to use an asp:label because this is rendered as a <span>.
>
Thanks in advance
>
John
>
>
>


Use a literal control.

MyLiteral.Text = "<h1>" + MyVariable + "</h1>";
Thank you Ray

I will read up on literal controls

John

Quote:

Originally Posted by

Quote:

Originally Posted by

>>


Use a literal control.
>
>
MyLiteral.Text = "<h1>" + MyVariable + "</h1>";
>


<h1><%# variable %></h1>

You can also use

<h1 id="hgcHeader" runat="server" />

and then in your code-behind, set the text as follows:

hgcHeader.InnerText = variable;

--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

"John Haycock" <jhayc@.blueyonder.co.ukwrote in message
news:1Jovg.2800$q97.1399@.fe3.news.blueyonder.co.uk ...

Quote:

Originally Posted by

Hi
>
I want to take a variable I have read from a database and place it in
<h1></h1tags on the web page. What's the best/easiest way to do this?
>
I don't want to use an asp:label because this is rendered as a <span>.
>
Thanks in advance
>
John
>
>


Cheers Chris it's good to know there are different ways to do this. I
haven't tried those out yet because I used a literal as suggested by Ray and
it worked a treat (cheers Ray) but I will definately try your methods on the
next one.

Many thanks

John
"Christopher Reed" <carttu@.nospam.nospamwrote in message
news:uUxCGqyqGHA.4424@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

<h1><%# variable %></h1>
>
You can also use
>
<h1 id="hgcHeader" runat="server" />
>
and then in your code-behind, set the text as follows:
>
hgcHeader.InnerText = variable;
>
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."
>


Glad it helped! :)

John Haycock wrote:

Quote:

Originally Posted by

Cheers Chris it's good to know there are different ways to do this. I
haven't tried those out yet because I used a literal as suggested by Ray and
it worked a treat (cheers Ray) but I will definately try your methods on the
next one.
>
Many thanks
>
John
"Christopher Reed" <carttu@.nospam.nospamwrote in message
news:uUxCGqyqGHA.4424@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

><h1><%# variable %></h1>
>>
>You can also use
>>
><h1 id="hgcHeader" runat="server" />
>>
>and then in your code-behind, set the text as follows:
>>
>hgcHeader.InnerText = variable;
>>
>--
>Christopher A. Reed
>"The oxen are slow, but the earth is patient."
>>


>
>
>

0 comments:

Post a Comment