There is a KendeUI editor option called encoded that sets whether the editor should send encoded HTML tags or not.
The default value for encoded is true
If you do not want to store unencrypted text, use this sniplet when creating your editor:
$("#Editor").kendoEditor({ encoded: false });
But because you are not sending encoded text to the server, the Asp.net request validation activist will abort your request.
If you use strongly typed views, what you can do is use AllowHtmlAttribute in the model property:
View:
@model MyModel @using(Html.BeginForm("SomeAction", "SomeController")) { @Html.TextAreaFor(m => m.Editor) <input type="submit" value="Save" /> } <script type="text/javascript"> $(function(){ $("#Editor").kendoEditor({ encoded: false }); }); </script>
Model:
public class MyModel { [AllowHtml] public string Editor { get; set; } }
Controller action
public ActionResult SomeAction(MyModel myModel) {
You also need to set the following in your web.config, or this attribute will have no effect in .NET 4.0:
<httpRuntime requestValidationMode="2.0"/>
nemesv
source share