我怎样才能从.cshtml动态数据库 [英] How can I get .cshtml from Database dynamically
问题描述
我不得不说:这是从这些不同的问题:
-
的http://crafty$c$cblog.com/2010/05/15/asp-net-mvc-render-partial-view-to-string/
-
<一个href=\"http://stackoverflow.com/questions/4344533/asp-net-mvc-razor-how-to-render-a-razor-partial-views-html-inside-the-controlle\">ASP.NET MVC剃刀:如何呈现剃刀局部视图的控制器动作里面HTML
-
的http:// blog.rocketbase.co.uk/2011/04/asp-net-mvc-virtual-path-provider/
我想提供从数据库动态.cshtml内容时,我想。
例如:
市表,FreeHtml列
@model市
@ Html.CheckBox - @ Model.Name - @ Html.CustomHelper
我怎么能写成的HTML帮助:
@model市
@ Html.RazorRaw(Model.FreeHtml,型号)
或CustomViewResult
公共RazorPartialViewResult CityHtml(城市)
{
返回新RazorPartialViewResult(city.FreeHtml,市)
}
我觉得你的答案就在这里:
存储ASP.Net MVC视图在数据库
您需要一个自定义,以取代默认的视图引擎(S)。
下面是一个例子:
<一href=\"http://weblogs.asp.net/imranbaloch/archive/2011/06/27/view-engine-with-dynamic-view-location.aspx\" rel=\"nofollow\">http://weblogs.asp.net/imranbaloch/archive/2011/06/27/view-engine-with-dynamic-view-location.aspx
I have to say: This is a different question from these:
http://craftycodeblog.com/2010/05/15/asp-net-mvc-render-partial-view-to-string/
ASP.NET MVC Razor: How to render a Razor Partial View's HTML inside the controller action
http://blog.rocketbase.co.uk/2011/04/asp-net-mvc-virtual-path-provider/
I want to provide dynamic .cshtml Content from db when i want.
Example:
City Table,FreeHtml Column
@model City @Html.CheckBox - @Model.Name - @Html.CustomHelper
How can I write as html helper:
@model City
@Html.RazorRaw(Model.FreeHtml,Model)
or as CustomViewResult
public RazorPartialViewResult CityHtml(City city)
{
return new RazorPartialViewResult(city.FreeHtml,city)
}
I think your answer is here: Storing ASP.Net MVC Views in the Database
You need to replace the default view engine(s) with a custom one. Here is an example: http://weblogs.asp.net/imranbaloch/archive/2011/06/27/view-engine-with-dynamic-view-location.aspx
这篇关于我怎样才能从.cshtml动态数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!