C# 从模型属性显示包含动态html内容的视图页面
在.Net MVC 3应用程序中,我需要实现以下功能: 当用户点击按钮时,它会引导他进入某个页面,但包含我在模型属性中拥有的html内容。可能吗 是的,这是可能的。 在这个新视图上使用C# 从模型属性显示包含动态html内容的视图页面,c#,jquery,asp.net,asp.net-mvc,C#,Jquery,Asp.net,Asp.net Mvc,在.Net MVC 3应用程序中,我需要实现以下功能: 当用户点击按钮时,它会引导他进入某个页面,但包含我在模型属性中拥有的html内容。可能吗 是的,这是可能的。 在这个新视图上使用 @Model YourModel @{ Layout = null; } @Html.Raw(Model.Propery) 是的,这是可能的。 在这个新视图上使用 @Model YourModel @{ Layout = null; } @Html.Raw(Model.Propery) 当
@Model YourModel
@{
Layout = null;
}
@Html.Raw(Model.Propery)
是的,这是可能的。
在这个新视图上使用
@Model YourModel
@{
Layout = null;
}
@Html.Raw(Model.Propery)
当然,在视图中:
@model MyViewModel
@{
Layout = null;
}
@Html.Raw(Model.SomePropertyThatContainsHtml)
但这完全是荒谬的,您宁愿让控制器操作直接返回ContentResult
:
public ActionResult SomeAction()
{
MyViewModel model = ...
return Content(model.SomePropertyThatContainsHtml, "text/html");
}
当然,在视图中:
@model MyViewModel
@{
Layout = null;
}
@Html.Raw(Model.SomePropertyThatContainsHtml)
但这完全是荒谬的,您宁愿让控制器操作直接返回ContentResult
:
public ActionResult SomeAction()
{
MyViewModel model = ...
return Content(model.SomePropertyThatContainsHtml, "text/html");
}
谢谢,所以请使用“建议我创建新视图”并在其上添加一些动态内容?在这个视图中,这是我唯一需要的代码?谢谢,所以请使用“建议我创建新视图”并在其上添加一些动态内容?在这个视图中,这是我唯一需要的代码?