I want to have a way in which I can add all my script from the page into a bag and render them before the tag.
My helper looks like:
public static MvcHtmlString Script(this HtmlHelper htmlHelper, string scriptBody)
{
htmlHelper.ViewContext.HttpContext.Items["_script_" + Guid.NewGuid()] = scriptBody;
return MvcHtmlString.Empty;
}
This is taken from: Using sections in Editor/Display templates The problem is that I cannot use it in my view like this:
@Html.Script(
{
<script type="text/javascript" src="somescript.js"> </script>
<script type="text/javascript"><!--
...script body
</script>
});
Is there any possibility to achieve something like this? I would like to have the intelisense for script but to send the text as a parameter to my helper. Do I ask for too much from MVC?