This should be easy

J

John Haycock

Hi

I want to take a variable I have read from a database and place it in
<h1></h1> tags 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
 
R

Ray Booysen

John said:
Hi

I want to take a variable I have read from a database and place it in
<h1></h1> tags 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>";
 
C

Christopher Reed

<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;
 
J

John Haycock

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
 
R

Ray Booysen

Glad it helped! :)

John said:
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
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top