1

I have an HtmlHelper function that returns a MvcHtmlString and which I'd like to call in an inline helper like this:

@helper JsCss()
{
    Html.Script("jquery/jquery-1.6.2", cdn: true)
}

I call the inline helper from my page:

<head>
@JsCss()
</head>

...trouble is: nothing shows up on the page! it seems I have to do this:

@helper JsCss()
{
    <text>
    @Html.Script("jquery/jquery-1.6.2", cdn: true)
    </text>
}

so I guess the thing is I have to "print" the return value of my Html.Script call to the page... how else could I do this?

ekkis
  • 9,804
  • 13
  • 55
  • 105

1 Answers1

2

A helper is a code block, you need to prefix the Html.Script with @ so Razor knows you want to output the return value (you don't need the <text></text>):

@helper JsCss()
{
    @Html.Script("jquery/jquery-1.6.2", cdn: true)
}
pjumble
  • 16,880
  • 6
  • 43
  • 51
  • I'm being a dope. 2 months of not touching this stuff and I've already forgotten! thanks – ekkis Feb 26 '12 at 02:55