Like the preview box below that take input from the textarea we are typing now.
The requirement is to retrieve HTML saved in database and preview it on the screen. Should I use label or is there any better control around?
Like the preview box below that take input from the textarea we are typing now.
The requirement is to retrieve HTML saved in database and preview it on the screen. Should I use label or is there any better control around?
Hi, I would use the literal control unless you need to do anything "extra" with the html. Cheers Tigger
If you simply need to output HTML, use a LiteralControl
- you simply set its Text
property to the HTML you need.
You may want to think about cleaning up the HTML, if it something that is user input, just in case of XSS attacks hiding in your HTML data.
I often use a DIV with a runat="server" attribute declared. That way, I have a container to apply CSS classes to, and I know and can control the markup that is being created.
A Literal will work fine if you don't need a container (or you have a container already on the page).
<div class="css-class">
<asp:Literal runat="server" />
</div>
OR
<div runat="server" class="css-class" />
And as Oded said, watch out for XSS by sanitizing your HTML.