Reputation: 2180
am getting above error "following sections have been defined but have not been rendered"
whenever I try to add style by razor calling syntax.
@section Styles {
@Styles.Render("~/Content/plugins/iCheck/iCheckStyles")
}
Am new to MVC5 Razor, so please can any one help ?
Upvotes: 0
Views: 255
Reputation:
In order to use @section Styles
, you layout being used by the view must include
@RenderSection("styles", false)
@RenderSection
acts as a placeholder in the layout to render any content that has been defined in in the section. In your case in means that the css files defined in the iCheckStyles
bundle will be rendered at the point in the view where @RenderSection
is declared. For css files, this would typically be in the <head>
tags immediately before @Scripts.Render("~/bundles/modernizr")
Note the second parameter defines whether the view requires a @section Styles { ... }
. If the value is false
, then @section Styles
is optional, other wise the view must include @section Styles
or an exception will be thrown.
Upvotes: 1