Adrian Rosca
Adrian Rosca

Reputation: 7412

Render Partial in WebPages without using MVC

I'm using Razor with WebPages but without MVC. I like the simplicity with this so I'm not interested in using MVC at this point. However I would like to be able to render a partial into my page. Like a menu, a footer, etc.

With MVC you can to this: @{ Html.RenderPartial("Footer", Model);}

I would like to do something similar: @{ Html.RenderPartial("footer.cshtml"); }

How can I achieve what I want?

Upvotes: 5

Views: 1974

Answers (1)

Yosra Galal
Yosra Galal

Reputation: 316

take a look at this link http://www.mikesdotnetting.com/Article/151/Extending-ASP.NET-Web-Pages-Create-Your-Own-Helpers

Hope this will help you

also try this:

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

Upvotes: 7

Related Questions