在不使用MVC的情况下在WebPages中渲染部分

时间:2013-03-27 08:15:47

标签: asp.net razor razor-2

我使用Razor和WebPages但没有MVC。我喜欢这种简单性,所以我现在对使用MVC不感兴趣。但是我希望能够将部分内容呈现在我的页面中。像菜单,页脚等

使用MVC你可以这样: @ {Html.RenderPartial(" Footer",Model);}

我想做类似的事情: @ {Html.RenderPartial(" footer.cshtml"); }

我如何实现我的目标?

1 个答案:

答案 0 :(得分:7)

查看此链接http://www.mikesdotnetting.com/Article/151/Extending-ASP.NET-Web-Pages-Create-Your-Own-Helpers

希望这会对你有所帮助

也试试这个:

<!DOCTYPE html>
<html>
  <head>
    <title>Main Page</title>
  </head>
  <body>
    @RenderPage("/Shared/_Header.cshtml")
    <h1>Index Page Content</h1>
    <p>This is the content of the main page.</p>
    @RenderPage("/Shared/_Footer.cshtml")
  </body>
</html>
相关问题