Creating an MVC 3 Razor project. have a very involved UI design. I wanted to put @renderbody() into a partial view source by _layout. The compiler won't let me. Is there a way to do this?
Instead of partial view you can go for master/sub layouts.
MasterLayout.cshtml
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title</title>
</head>
<body>
@RenderBody()
</body>
</html>
Layout.cshtml
@{
Layout = "~/Views/Shared/_MasterLayout.cshtml";
}
// html code above render body
@RenderBody()
// html code below render body
Your sublayout(Layout.cshtml
) contains the code that should be in the partial view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With