views:

171

answers:

1

I have a formatted text that contains Bolded, italicsed, and other styles implemented inside the message. I have this message stored in a Database. Now I want to implement these tags into work inside the a field inside the DataList. How do I do it?

<%# Eval("message") %>

Doesn't work. It just shows up the tags as such. Any help?

A: 

If you mean that your "message" contains formatted HTML, you should simply HTMLDecode it after the DataBinder has evaluated the value of the "message" property. For example:

' "message" contains the string "<b>Hello World!</b>"
' Within the DataList:
<ItemTemplate>
  <asp:Label ID="lbl1" runat="server" Text='<%# Server.HtmlDecode(Eval("message").ToString()) %>' />
</ItemTemplate>
Cerebrus
That answers me.
How do I mark this answer as "Good answer" ? no provision?
Ah I'm blind. lol
lol, np. You can vote up answers that you think have merit. You can also vote up answers that you have accepted. Thanks for accepting! :-)
Cerebrus