Abhay Andhariya
Abhay Andhariya

Reputation: 2157

How to make HTML tag take effect automatically in mvc Razor View?

I have following type of data stored in my database field

<p>sdf'jsdfkl''jksdl;fj/ sdfjklf'' Hiee</p>
<p> </p>
<p><strong>dfgdgdgfgsd</strong></p>
<p><strong>fsfsfsf</strong></p>
<p><strong>dfsfsdff</strong></p>
<p> </p>
<p><strong><img src="../Scripts/tinymce/plugins/emoticons/img/smiley-cool.gif" alt="" /></strong></p>
<p> </p>
<p>Hie this text comes out from TextEditor.. 'sf'fsfdfs'df'f''""'"sdfsfskfkf/lfdjklsfj\jslfjklff</p>

I have stored it in SQL server in ASP.net C# using HttpUtility.HtmlEncode() method.

Now i want to retrieve that data from database and want to display it without html tags..

For that I have used HttpUtility.HtmlDecode(), but that only decodes and generate tags and generated following result

<p>sdf'jsdfkl''jksdl;fj/ sdfjklf'' Hiee</p> <p>&nbsp;</p> <p><strong>dfgdgdgfgsd</strong></p> <p><strong>fsfsfsf</strong></p> <p><strong>dfsfsdff</strong></p> <p>&nbsp;</p> <p><strong><img src="../Scripts/tinymce/plugins/emoticons/img/smiley-cool.gif" alt="" /></strong></p> <p>&nbsp;</p> <p>Hie this text comes out from TextEditor.. 'sf'fsfdfs'df'f''""'"sdfsfskfkf/lfdjklsfj\jslfjklff</p>

I don't want to display all these tags, instead just want to display text, so what should i do??

Upvotes: 0

Views: 1357

Answers (1)

Harshit Tailor
Harshit Tailor

Reputation: 3281

You can use Html.Raw() on view or partial view for display html.

Html.Raw("<div class=\"resource-row\">").ToString()

Upvotes: 2

Related Questions