0

I am trying to display my blog content that is stored in my database in the form of raw html tags and img tags. I tried using HTML Encode before inserting data in the database and Decode while retrieving the data. After doing so I am getting an output like this.

enter image description here

I want to get an output like thisenter image description here

I tried doing this but nothing worked

//code to put this text into the database
string text = Server.HTMLEncode(userEnteredText);

//code to put while fetching data from DB
string text = Server.HTMLDecode(userEnteredText);

Please note I am using Webforms and not MVC framework

I would be obliged if anyone could help me with this.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user3818870
  • 25
  • 1
  • 9

1 Answers1

1

You should try LiteralControl

With this you can inject Html into your page at runtime like so:

this.Controls.Add("<h1>Hello World</h1>");
this.Controls.Add(userEnteredText);

Further reading:

//EDIT:

Take an Water bottle

Is wrong from my little understanding of the English language. It should be "Take a water bottle" A is only attached with the suffix n in case the next word starts with a vowel (a, e, i, o, u).

Community
  • 1
  • 1
Marco
  • 22,856
  • 9
  • 75
  • 124
  • Thanks for your quick response I tried using Literal control earlier but it dint seem to work.I'll try using the reference you have mentioned above and see if that does the trick – user3818870 Dec 12 '14 at 13:43