Kra*_*mir 3 asp.net-mvc kendo-ui
我在文本框中使用了Kendo.EditorFor但是在视图中.它显示了来自编辑器的htmls标签这是我的控制器:
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");
}
Run Code Online (Sandbox Code Playgroud)
我看到<strong>123123</strong>在我的视野.我应该在HtmlDecode别的地方还是?
我在我的视图中试过这个:
@(Html.Kendo().EditorFor(model => model.Content).Encode(false))
Run Code Online (Sandbox Code Playgroud)
但是这给了我错误:
A potentially dangerous Request.Form value was detected from the client
如果你使用html helper,你可以在从视图中将它们接收到控制器后对其进行解码.
它来自他们的文档:这是链接
处理服务器上的编辑器值
编辑器值将作为字符串发布,并映射到具有窗口小部件名称的变量.请注意,默认情况下,发布的值是HTML编码的,以避免ASP.NET请求验证.要解码该值,请使用HttpUtility.HtmlDecode方法.
[HttpPost]
public ActionResult Save(string editor)
{
string value = HttpUtility.HtmlDecode(editor);
return View();
}
Run Code Online (Sandbox Code Playgroud)
我认为这就是你要找的东西
| 归档时间: |
|
| 查看次数: |
9314 次 |
| 最近记录: |