[CLOSED] Error with ResourcePlaceholder for scripts in MVC: Reference token (ext.net.initscriptfiles) was not found.

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Error with ResourcePlaceholder for scripts in MVC: Reference token (ext.net.initscriptfiles) was not found.

    Hi,

    I have latest code, and a simple test MVC view:

    @{
        Layout = null;
    }
    <!DOCTYPE html>
    <html>
        <head>
            <title>Resource placeholder test</title>
        
            @Html.X().ResourcePlaceHolder(ResourceMode.Style)
        
            @Html.X().ResourcePlaceHolder(ResourceMode.Script)
        </head>
        <body>
            @Html.X().ResourceManager()
            
            <p>Test</p>
        </body>
    </html>
    The controller is this:

    using System.Web.Mvc;
    
    namespace Ext.Net2.Tests.Controllers
    {
        public class ResourcePlaceholderTestController : Controller
        {
            //
            // GET: /ResourcePlaceholderTest
            //
            public ActionResult Index()
            {
                return View();
            }
        }
    }
    When I run this page I get the following error:

    ItemTag validation (_tkn_1): Reference token (ext.net.initscriptfiles) was not found.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    
    Exception Details: System.Exception: ItemTag validation (_tkn_1): Reference token (ext.net.initscriptfiles) was not found.
    
    Source Error:
    
    
    Line 137:                }
    Line 138:
    Line 139:                throw;
    Line 140:            }
    Line 141:        }
    
    
    Source File: d:\Ext.Net\2.x\Ext.Net\Core\ExtNetTransformer.cs    Line: 139
    
    Stack Trace:
    
    
    [Exception: ItemTag validation (_tkn_1): Reference token (ext.net.initscriptfiles) was not found.]
       Transformer.NET.ItemTag.Validate() +156
       Transformer.NET.TextTransformer.Handle() +159
       Transformer.NET.TextTransformer.Transform(List`1 tokensType, Dictionary`2 variables) +28
       Transformer.NET.TextTransformer.Transform(List`1 tokensType) +11
       Transformer.NET.TextTransformer.Transform() +27
       Ext.Net.ExtNetTransformer.Transform(String text) in d:\Ext.Net\2.x\Ext.Net\Core\ExtNetTransformer.cs:139
       Ext.Net.InitScriptFilter.Transform() in d:\Ext.Net\2.x\Ext.Net\Core\InitScriptFilter.cs:69
       Ext.Net.InitScriptFilter.Flush() in d:\Ext.Net\2.x\Ext.Net\Core\InitScriptFilter.cs:57
       System.Web.HttpWriter.FilterIntegrated(Boolean finalFiltering, IIS7WorkerRequest wr) +9684129
       System.Web.HttpResponse.FilterOutput() +104
       System.Web.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +49
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
    The CSS resources placeholder is fine; it is just the JavaScript placeholder that doesn't work. If I comment out or remove this line, then the error goes away:

    @Html.X().ResourcePlaceHolder(ResourceMode.Script)
    If it helps, I also created a new project and installed the latest Ext.NET.MVC Package from NuGet, and edited the Ext.NET razor view to insert the two resource placeholders, and got the same error.
    Last edited by Daniil; Nov 22, 2013 at 10:31 AM. Reason: [CLOSED]
  2. #2
    I posted too soon - I tried with mode of ScriptFiles instead of just Script and it worked

    @Html.X().ResourcePlaceHolder(ResourceMode.ScriptFiles)
    I guess I made the mistake when converting an ASP.NET page that had this:
    <ext:ResourcePlaceHolder Mode="Script" runat="server" />
    What is the difference between Script and ScriptFiles resource modes, then?

    Thanks!
  3. #3
    Hi Anup,

    "Script" means an initialization Ext.onReady() script.

    "ScriptFiles" means the JavaScript resources (like ext-all.js and extnet-all.js).
  4. #4
    Thanks for the explanation, Daniil.

    In WebForms I had always been using

    <ext:ResourcePlaceHolder Mode="Script" runat="server" />
    So how come that works for WebForms?
  5. #5
    Mode.Script should work in both, WebForms and MVC.

    We are investigating why it crashes in MVC. Thank you for the report.
  6. #6
    This should be fixed in the trunk. Please update.
  7. #7
    Thanks for such a quick turnaround. That seems to work now.

    That being said, should I continue to use ScriptFiles instead of Script?
  8. #8
    Well, I am not sure. it depends on your requirements.

    This
    @{
        var X = Html.X();
    }
    
    <!DOCTYPE html>
    <html>
    <head>
        <title>ResourcePlaceHolder ResourceMode.Script test</title>
         
        @X.ResourcePlaceHolder(ResourceMode.ScriptFiles)
    
        <script>
            /* my scripts */
        </script>
    </head>
    <body>
        @X.ResourceManager()
    
        @X.Panel()
    </body>
    </html>
    produces:
    <!DOCTYPE html>
    <html>
    
    <head>
        <link type="text/css" rel="stylesheet" href="/extjs/resources/ext_theme_classic/ext-theme-classic-all-debug-embedded-css/ext.axd?v=14276" id="ext-theme" />
        <link type="text/css" rel="stylesheet" href="/extnet/resources/css/extnet-all-embedded-debug-css/ext.axd?v=14276" id="extnet-styles" />
        <title>ResourcePlaceHolder ResourceMode.Script test</title>
    
    
        <script type="text/javascript" src="/extjs/ext-all-dev-js/ext.axd?v=14276"></script>
        <script type="text/javascript" src="/extnet/extnet-all-debug-js/ext.axd?v=14276"></script>
        <script type="text/javascript" src="/extnet/locale/ext-lang-ru-js/ext.axd?v=14276"></script>
        <script>
            /* my scripts */
        </script>
    
        <script type="text/javascript">
            //<![CDATA[
            Ext.net.ResourceMgr.init({
                isMVC: true
            });
            Ext.onReady(function () {
                Ext.create("Ext.panel.Panel", {
                    renderTo: "App.idc9743e8d6d113f36_Container"
                });
            });
             //]]>
        </script>
    </head>
    <body>
        <div id="App.idc9743e8d6d113f36_Container"></div>
    </body>
    </html>
    Notice that the "my scripts" follows after the resources scripts, but before the Ext.onReady() script.

    But this:
    @{
        var X = Html.X();
    }
    
    <!DOCTYPE html>
    <html>
    <head>
        <title>ResourcePlaceHolder ResourceMode.Script test</title>
         
        @X.ResourcePlaceHolder(ResourceMode.Script)
    
        <script>
            /* my scripts */
        </script>
    </head>
    <body>
        @X.ResourceManager()
    
        @X.Panel()
    </body>
    </html>
    produces:
    <!DOCTYPE html>
    <html>
    
    <head>
        <link type="text/css" rel="stylesheet" href="/extjs/resources/ext_theme_classic/ext-theme-classic-all-debug-embedded-css/ext.axd?v=14276" id="ext-theme" />
        <link type="text/css" rel="stylesheet" href="/extnet/resources/css/extnet-all-embedded-debug-css/ext.axd?v=14276" id="extnet-styles" />
        <title>ResourcePlaceHolder ResourceMode.Script test</title>
    
    
        <script type="text/javascript" src="/extjs/ext-all-dev-js/ext.axd?v=14276"></script>
        <script type="text/javascript" src="/extnet/extnet-all-debug-js/ext.axd?v=14276"></script>
        <script type="text/javascript" src="/extnet/locale/ext-lang-ru-js/ext.axd?v=14276"></script>
    
        <script type="text/javascript">
            //<![CDATA[
            Ext.net.ResourceMgr.init({
                isMVC: true
            });
            Ext.onReady(function () {
                Ext.create("Ext.panel.Panel", {
                    renderTo: "App.id987acea1c48d74e1_Container"
                });
            });
             //]]>
        </script>
        <script>
            /* my scripts */
        </script>
    </head>
    <body>
        <div id="App.id987acea1c48d74e1_Container"></div>
    </body>
    </html>
    Notice that the "my scripts" follows after the resources scripts and the Ext.onReady() script.

    For example, if you override some Ext.NET/ExtJS components, this should be executed before an Ext.onReady() script. So, the ScriptFiles mode is a way to go. If you need your JavaScript to be executed after an Ext.onReady() script, then the Script mode is a way to go.
  9. #9
    Ah, I see. Thanks for that awesome explanation! Makes sense, and very useful.

    (Maybe it is worth adding XML comments into that enum for those options so that these explanations are available to developers via IntelliSense?)

    I think you can mark this as closed (there is another issue I have seen with Statusbar, as we've separately discussed. I don't know if it is related to this thread, so I'll create a new post instead?)
  10. #10
    Quote Originally Posted by anup View Post
    (Maybe it is worth adding XML comments into that enum for those options so that these explanations are available to developers via IntelliSense?)
    A nice suggestion, thank you. Do you think it is good enough?
    public enum ResourceMode
    {
        /// <summary>
        /// Renders the Ext.NET and ExtJS CSS styles.
        /// </summary>
        Style,
    
        /// <summary>
        /// Renders the Ext.NET and ExtJS JavaScript files and the initialization script (Ext.onReady())
        /// </summary>
        Script,
    
        /// <summary>
        /// Renders the Ext.NET and ExtJS JavaScript files. The initialization script (Ext.onReady()) is not rendered.
        /// </summary>
        ScriptFiles
    }
    Quote Originally Posted by anup View Post
    I think you can mark this as closed (there is another issue I have seen with Statusbar, as we've separately discussed. I don't know if it is related to this thread, so I'll create a new post instead?)
    Well, I think the both would be OK in that case. Though, I am too late. For references:
    http://forums.ext.net/showthread.php?27304
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Token is not unique error for nested grid
    By alscg in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 01, 2013, 4:53 AM
  2. [CLOSED] Reference token (ext.net.initscriptfiles) was not found.
    By jesperhp in forum 2.x Legacy Premium Help
    Replies: 14
    Last Post: Oct 08, 2013, 10:24 AM
  3. Replies: 5
    Last Post: Jun 11, 2013, 7:46 AM
  4. Replies: 5
    Last Post: Nov 12, 2012, 7:41 AM
  5. Replies: 4
    Last Post: Mar 30, 2012, 7:30 PM

Tags for this Thread

Posting Permissions