Want to put @renderbody () in the _layout partial view source

Creation of the MVC 3 Razor project. have a very sophisticated user interface design. I wanted to put @renderbody () in the source part source using _layout. The compiler will not allow me. Is there any way to do this?

+4
source share
1 answer

Instead of partial viewing, you can go to 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 Layout.cshtml ( Layout.cshtml ) contains the code, which should be in a partial view.

+8
source

All Articles