I have content that I want to load dynamically, the problem is it has some html formatting in it. What control should i pull the text into, is there a way to pull the text into a div or a label, along with the formatting?
1 Answer
You can use an asp:Literal:
Code behind:
myLiteral.Text = HtmlDecode(GetTextFromDB())
3 Comments
Joel Etherton
Just make sure to be careful about the kind of html formatting allowed. Being able to inject javascript into a database entry can be a source of XSS.
MyHeadHurts
thank you i ahve never worked with an asp literal, how would i get the data from my sqldatasource to the literal
Karel
I would'nt use an sqlDataSource. You can access your db through ADO or Linq and then set the Text property of the literal.