0

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 1

4

You can use an asp:Literal:

Code behind:

myLiteral.Text = HtmlDecode(GetTextFromDB())

Sign up to request clarification or add additional context in comments.

3 Comments

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.
thank you i ahve never worked with an asp literal, how would i get the data from my sqldatasource to the literal
I would'nt use an sqlDataSource. You can access your db through ADO or Linq and then set the Text property of the literal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.