In _Layout.cshtml
file I have such method @RenderSection("head", false)
.
In partial view UploadForm.cshtml
I have code below.
When I run web app the head
section is not rendered. How to solve this problem?
@section head
{
<script type="text/javascript">
//skip
</script>
}
You can only call RenderSection between two Views/Layouts that are directly related. From what you say it looks like your page structure is something like:
UploadForm (section defined here) -> UnknownView -> _Layout (RenderSection called here)
In this situation you would need to essentially redefine and render the section in your View in the middle.
See: http://blogs.msdn.com/b/marcinon/archive/2010/12/15/razor-nested-layouts-and-redefined-sections.aspx for a clearer explanation
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