Using Script.Require in .cshtml file

Feb 10, 2011 at 12:02 PM

I keep getting the error :

Compiler Error Message: CS0103: The name 'Script' does not exist in the current context

Source Error:


Line 6:  @*using System.Web.Script;*@
Line 7:
Line 8: @Script.Require("flowPlayer");
Line 9:
Line 10:



I seem to be having problem trying to use the Script.require method in my razor file:


@using System.Web.Routing;
@using Orchard.Utility.Extensions;
@model Flowplayer.Models.Video

@Script.Require("flowPlayer");

 

I have reference the .js file in my ResourceManifest.cs file:

 

namespace FlowPlayer {
    using Orchard.UI.Resources;
    public class ResourceManifest : IResourceManifestProvider {
        public void BuildManifests(ResourceManifestBuilder builder) {
            var manifest = builder.Add();
            //manifest.DefineScript("jQuery").SetUrl("jquery-1.4.2.min.js", "jquery-1.4.2.js").SetVersion("1.4.2");
            manifest.DefineScript("flowPlayer").SetUrl("flowplayer-3.2.4.min.js").SetVersion("3.2.4");
            // todo: include min versions
          
        }
    }
}

 

 

I think it could be the fact that I had to change some references in the web.config file which might be missing an assembly in order to use the "Script.require" method in Orchard.

My web.config looks like :

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=152368
  -->

<configuration>
    <appSettings>
        <add key="ClientValidationEnabled" value="true"/>
        <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
    </appSettings>

    <system.web>
        <compilation debug="true" targetFramework="4.0">
            <assemblies>
                <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                <!--<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />-->
               
            </assemblies>
        </compilation>
        <pages>
            <namespaces>
                <add namespace="System.Web.Helpers" />
                <!--<add namespace="System.Web.Extensions" />-->
                <add namespace="System.Web.Mvc" />
                <add namespace="System.Web.Mvc.Ajax" />
                <add namespace="System.Web.Mvc.Html" />
                <add namespace="System.Web.Routing" />
                <add namespace="System.Web.WebPages"/>
                <add namespace="Orchard.Mvc.Html"/>
                <add namespace="System.Linq"/>
                <add namespace="System.Collections.Generic"/>
            </namespaces>
        </pages>
    </system.web>

    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

 

Any help would be much appreciated!

 

Coordinator
Feb 10, 2011 at 5:28 PM

Why did you have to change web.config?