Click here to Skip to main content
16,018,650 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
Hello folks ,

I am stuck with this issue. I am fetching a HTML string from database and I want to display it in a panel on aspx page.

My string is like <html> <body> HTML Code</body> </html> .

I want to display this HTML in a window/ panel on aspx

Can someone please suggest any way ? Any help would be appreciated .

Thanks,
Posted
Comments
Sergey Alexandrovich Kryukov 2-Aug-12 13:07pm    
What's the problem? Perhaps you don't know how to escape all those "<" and ">"?
--SA

VB
step 1: make the panel control runat="server"
step 2:remove html and body tag from your string
step 3:using panel id in .cs file id.controls.add(new LiteralControl(your string))


and if you want to display in iframe then use id.innerHtml=your string
 
Share this answer
 
v2
As I have not idea what is your difficulties, I just assumed you have one of the most common problem: encoding of HTML entities. If so, please see:
http://msdn.microsoft.com/en-us/library/73z22y6h.aspx[^].

See the class System.Web.HttpUtility:
http://msdn.microsoft.com/en-us/library/system.web.httputility.aspx[^].

If you have other problems, please don't blame me: you did not tell us about them. You are welcome to ask other questions.

[EDIT, after OP's clarification]

Perhaps iframe is not what you need, because its content is external to your HTML file, is loaded from an external file. You would need to create a separate HTML file with the content taken from your database, generate iframe element with the attribute src, set the attribute's value to the name of the generated file. This would be too ugly.

You should better use any block element like div and set its attribute innerHTML to the content taken from your database. It cannot be the whole HTML file though, only the HTML fragment which is valid under the div element.

If both solutions are not good enough for you (which can happen), you should review your design. After all, your requirement is not to use iframe or something certain. You just need certain rendering applied dynamically.

—SA
 
Share this answer
 
v2
Comments
amit_sept12 2-Aug-12 13:30pm    
Hi Sergey

I have entire well formed HTML string and I want to render it in Iframe
Sergey Alexandrovich Kryukov 2-Aug-12 15:41pm    
Was you purpose to waste some of my time? Such things should be explained in first place. Please see my update above, after [EDIT].
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900