我怎样才能从.cshtml动态数据库 [英] How can I get .cshtml from Database dynamically

查看:167
本文介绍了我怎样才能从.cshtml动态数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不说:这是从这些不同的问题:

我想提供从数据库动态.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:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆