Reputation: 259
I use Kendo.EditorFor for textbox but in view .It's show me htmls tag from editor this is my controller:
public ActionResult Create(OpininonModel opininonmodel)
{
var addOpinion =
new OpininonModel
{
Title=opininonmodel.Title,
Content=Server.HtmlDecode(opininonmodel.Content),
Id=opininonmodel.Id,
IdUser=user,
};
db.Opinions.Add(addOpinion);
db.SaveChanges();
return RedirectToAction("Index");
}
And i see <strong>123123</strong>
in my view. Should I HtmlDecode
somewhere else or ?
I tried this in my View :
@(Html.Kendo().EditorFor(model => model.Content).Encode(false))
but this give it to me error:
A potentially dangerous Request.Form value was detected from the client
Upvotes: 3
Views: 11731
Reputation: 338
When you use $('.editor').kendoEditor() //without encoded:false you should do in controller:
model.data = WebUtility.HtmlDecode(model.data);
ModelState.Clear();
Upvotes: 0
Reputation: 1350
Could you please try with encoded: false
$('.editor').kendoEditor({
encoded: false
});
Upvotes: 4
Reputation: 1350
if you use html helper that you can decode the value once you received them from your view to your controller.
its from their documentation: Here is the link
Processing the editor value on the server
The editor value will be posted as a string and mapped to a variable with the name of the widget. Note that the posted value is HTML-encoded by default, in order to circumvent the ASP.NET request validation. In order to decode the value, use the HttpUtility.HtmlDecode method.
[HttpPost]
public ActionResult Save(string editor)
{
string value = HttpUtility.HtmlDecode(editor);
return View();
}
i think this is what you looking for
Upvotes: 8