2013-03-27 81 views
5

我在使用WebPages的Razor但沒有使用MVC。我喜歡這種簡單性,所以我現在對使用MVC不感興趣。不過,我希望能夠在我的頁面中顯示部分內容。就像一個菜單,頁腳等在不使用MVC的情況下在WebPages中渲染部分內容

在MVC中,你可以這樣: @ {Html.RenderPartial( 「頁腳」,模型);}

我願做同樣的事情: @ { Html.RenderPartial( 「footer.cshtml」); }

我該如何實現我想要的?

回答

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> 
+0

的'@ RenderPage'作品完全一樣我想要的。 '@ helper'(來自教程)對我來說也非常有用。很多感謝! – 2013-03-27 16:19:15

+1

@ engineer.oop鏈接已損壞,您可以在這裏寫下mikesdotnetting解決方案的精髓嗎? – tsemer 2014-04-09 09:14:40

相關問題