剃刀控制编程的看法? [英] Controlling Razor views programmatically?

查看:120
本文介绍了剃刀控制编程的看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时,可以通过编程来控制剃刀的看法?我可以达到不同的 RenderSection 部分或更改code中的布局定义?

Is is possible to programmatically control Razor views? Can I reach the different RenderSection parts or change the Layout definition in code?

我在寻找进入的可能性,使用剃刀语法在CMS应用程序的presentation层。可能引发是一个更好的选择,因为它的(可解析)的XML语法?

I'm looking into possibilities to use Razor syntax in the presentation layer of a CMS application. Might Spark be a better choice because of it's (parseable) XML syntax?

推荐答案

看看的http:// razorengine 。codeplex.com 并的 http://tqcblog.com/2011/01/23/$p$pcompiled-razor-for-shared-views-and-mono/ - 你可以剃须刀意见转换成C#code和设置的意见,使用有你需要的任何额外功能的自定义的基类。

Take a look at http://razorengine.codeplex.com and http://tqcblog.com/2011/01/23/precompiled-razor-for-shared-views-and-mono/ - you can convert razor views to c# code and set the views to use a custom base class that has whatever additional functionality you need.

您还可以做一些与viewstart文件 - 虽然设置为剃刀认为,这实际上是自定义的code,它会修改所有视图的设置,包括布局

You may also be able do something with the viewstart file - although set up as a razor view, it is effectively custom code that modifies the settings of all views, including the layout.

这篇关于剃刀控制编程的看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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