将html字符串转换为Razor视图 [英] Convert a html String to a Razor View
本文介绍了将html字符串转换为Razor视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi every body.
I create a mvc3 app.
I use a ckeditor in my App for save news.I have a Content class for model:
<pre lang="c#">
public class Content
{
[AllowHtml]
public string Text { get; set; }
}
这是我的剃须刀查看代码:
this is My razor view code:
@model Myapp.Models.Content
@{
ViewBag.Title = "Content Entry";
}
<html>
<head>
<title></title>
<script src="@Url.Content("~/ckeditor/ckeditor.js")" type="text/javascript"></script>
</head>
<body>
@using (Html.BeginForm("Editor", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.TextAreaFor(model => model.Text, new { @class = "ckeditor", @id = "text-details" })
<p><input type="submit" value="Submit" /></p>
}
</body></html>
这是我的控制器:
this is my controller:
[HttpPost]
[ValidateInput(false)]
public ActionResult Editor(Content model)
{
ViewBag.Text = model.Text;
return View();
}
我在我的控制器中得到html字符串。我想发送这个字符串来查看和显示。我能做到吗? br />
谢谢。
I get html string in my controller.I want to send this string to view and shown.how I can do it?
thanks.
推荐答案
Ok.I find Answer.
I use this and my problem is solved.
<pre lang="HTML">
@Html.Raw(Model.Text)
但我不会删除这个问题的人有这样的问题。
But I do not delete this question for guys that have such problem.
这篇关于将html字符串转换为Razor视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文