Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从模型属性显示包含动态html内容的视图页面_C#_Jquery_Asp.net_Asp.net Mvc - Fatal编程技术网

C# 从模型属性显示包含动态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) 当

在.Net MVC 3应用程序中,我需要实现以下功能: 当用户点击按钮时,它会引导他进入某个页面,但包含我在模型属性中拥有的html内容。可能吗

是的,这是可能的。 在这个新视图上使用

@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");
}

谢谢,所以请使用“建议我创建新视图”并在其上添加一些动态内容?在这个视图中,这是我唯一需要的代码?谢谢,所以请使用“建议我创建新视图”并在其上添加一些动态内容?在这个视图中,这是我唯一需要的代码?