Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Willem 6 posts 26 karma points
    Jan 10, 2014 @ 14:13
    Willem
    0

    How to render sections from a SurfaceController view

    My _layout.cs template contains the following code:

    @RenderSection("Scripts", false)
    

    How can I inject some code into that section from within a surface controller view? In MVC I would do:

    @section Scripts
    {
        <!-- Add HTML here -->
    }
    

    I know this is probably not the right route, but please advise an alternative method. thank you in advance.

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Jan 10, 2014 @ 20:44
    Andy Butland
    0

    I think the issue you are running into is that from your Surface Controller you are likely returning a partial view, not a view, from where you can't use sections. That link appears to suggest some ways around it, but can't say I've tried any.  I think you would just need to add the @section tag the scripts to your view (template) rather than the partial view you are returning from your controller.

    Andy

Please Sign in or register to post replies

Write your reply to:

Draft