'Making a custom section\helper in cshtml

So the following code renders the result to the Something section defined in the layout

@section Something {
    <h1>Hello</h1>
}

Is there a way that one could write their own "@section" helper... or some way to add custom HTML into a helper that can be parsed?

The usecase is I need to be able to take a chunk of html (in the cshtml view) and render it to a different part of the page. The CMS doesn't understand the @section system, it's not supported.

They do have helpers that can do this

@Html.Script("file.js", "bottom")

...and render that in the "bottom" section.

So I would LOVE to be able to take that concept and allow freeform HTML somehow, then through the code place it into a defined section, but I'm not sure if this is even possible (not the moving\rendering, but the ability to define something in the cshtml).



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source