How to set innerHTML of an asp Label control

M

moondaddy

I want to use a asp Label control (or a <div runat=server> element) in a
template column of a datagrid. In the code behind in the grid's
ItemDataBound event I need to dynamically set the innerHTML of this control
with data and line breaks (<br>).

The problem is that while working in the code behind, I don't see any
properties for this control where I can set innerHTML, only text.

Any good ideas?
 
S

Steven Cheng[MSFT]

Hi Moondaddy,

As for the problem how to set the innerHTML of a ASP Label Control. I think
you can directly use its "Text" property. For example:

if we have a Label control as below:
<asp:Label id="lblHtml" runat="server"></asp:Label>

Then in code behind, we can set its innerHtml like this:
lblHtml.Text = "<table width='200'
border='1'><tr><td>content</td></tr></table>";

So the only thing we need to do is just retrieve the certain Label Control
from the certain cell in the DataGrid in
its ItemDataBound event and then use its "Text" property to set the
innerHtml. Please have a try to see whether this helps. Thanks.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

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,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top