Question

I'm looking to implement loading jQuery from the Google Content Delivery Network. The issue I'm having is that the recommended script from HTML5 Boilerplate is causing the Razor view to lose sight of it's closing curly bracket.

I've tracked it down to the last script line, in the code below. The IDE seems convinced that it doesn't have a closing tag (unsure if it's VS2010, or Resharper reporting it).

In the View:

@if ([Decision...])
{

    <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"> </script>
    <script type="text/javascript">(window.jQuery || document.write('<script src="/Scripts/jquery-1.6.3.min.js"><\/script>')) </script>
}

And running it gives an error about the closing bracket:

Parser Error Message: The if block is missing a closing `"}" character.  Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.`

Suggestions as to how to modify the script to suit Razor?

Était-ce utile?

La solution

@if ([Decision...])
{
    <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
    @:<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"> </script>
    @:<script type="text/javascript">(window.jQuery || document.write('<script src="/Scripts/jquery-1.6.3.min.js"><\/script>'))</script>
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top