This is a migrated thread and some comments may be shown as answers.

[Solved] How do I prevent html tags from appearing in output from editor

1 Answer 29 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jome Akpoduado
Top achievements
Rank 1
Jome Akpoduado asked on 14 Mar 2011, 09:06 AM
Hello,
I'm digging my hands into the MVC editor for the first time. I'm encountering this problem. When I wish to display the value of the editor in another page, I still get the html tags showing in the output like this...
<p>Welcome!!</p><p>Example text to be shown in browser</p>
I would like for this to be rendered as
Welcome
Example text to be shown in browser

Is there a way to make this happen without setting ValidateRequest to false?

Thanks.

1 Answer, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 14 Mar 2011, 10:44 AM
Hi Jome,

Thank you for your interest in our products.

You should decode the editor value before storing or displaying it as outlined in the introduction topic:

public ActionResult Save(string notes)
{
   // HTML decode the value before using it.
   notes = System.Web.HttpUtility.HtmlDecode(notes);
 
   // ...
}

If you're using the Razor view engine then you need to prevent the automatic encoding:
@Html.Raw((string)ViewData["value"])

I hope this helps.

Best Regards,
Tsvetomir Tsonev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
General Discussions
Asked by
Jome Akpoduado
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or