0

Let me explain in detail There is textarea in form. On submitting form,the text of textarea get stored in database. While display those texts from database I want to execute basic html code like <b><i><u>...etc For example:-If user entered "<b>hello</b>" in textarea.Then this word "hello" will display in bold letters.

2 Answers2

3

Use @Html.Raw( [your HTML code from the database] ) in your View.

QQping
  • 1,370
  • 1
  • 13
  • 26
  • @Champ726337: It's pretty much all or nothing with HTML. You could strip anything between <> characters that doesn't match those tags, if you want to dive into the magical lands of Regex. – Jeff Apr 29 '13 at 14:10
  • Thank QQping I got my answer'if(str.Contains("")){ Html.Raw(str) } else{ str }' – Sameer Carpenter Apr 29 '13 at 14:41
0

In your Razor-file:

 <b>@myHtmlFromTheDatabase</b>
Martin Mulder
  • 12,642
  • 3
  • 25
  • 54
  • @Champ726337: In that case: clearify your question. Or at least: ask a question. I had the impression you that the textarea and database part were already done and you could not fix the last step... – Martin Mulder Apr 29 '13 at 14:23
  • I just take an example to explain what I want in last line – Sameer Carpenter Apr 29 '13 at 14:28