示例#1
0
        public void WritePageScripts()
        {
            JavascriptPage target = this.page;

            // add core scripts.  the core script will always go in the header
            foreach (string scriptName in coreScripts)
            {
                if (target.Header != null)
                {
                    target.Header.Controls.AddAt(0, CreateResourceScriptControlFromQualifiedName(scriptName));
                }
            }

            // add header resource scripts
            foreach (string scriptName in resourceHeaderScripts)
            {
                if (target.Header != null)
                {
                    target.Header.Controls.Add(CreateResourceScriptControlFromQualifiedName(scriptName));
                }
            }
            // add body resource scripts
            foreach (string scriptName in resourceBodyScripts)
            {
                if (target.Form != null)
                {
                    target.Form.Controls.Add(CreateResourceScriptControlFromQualifiedName(scriptName));
                }
            }

            // add header site scripts
            foreach (string scriptPath in siteHeaderScripts)
            {
                if (target.Header != null)
                {
                    target.Header.Controls.Add(CreateScriptControl(target.Request.ApplicationPath + scriptPath));
                }
            }
            // add body site scripts
            foreach (string scriptPath in siteBodyScripts)
            {
                if (target.Form != null)
                {
                    target.Form.Controls.Add(CreateScriptControl(target.Request.ApplicationPath + scriptPath));
                }
            }
        }
示例#2
0
        public static void RegisterResourceScripts(Page page, Assembly assemblyToLoadFrom, params string[] scriptNames)
        {
            if (HttpContext.Current == null)
            {
                throw NewInvalidOperationException();
            }

            Resources.Load(assemblyToLoadFrom);

            foreach (string script in scriptNames)
            {
                string         scriptPath     = GetResourceScriptPath(page.Request.Url, script);
                JavascriptPage javascriptPage = page as JavascriptPage; // "as" casting to prevent InvalidCastException

                if (javascriptPage != null)
                {
                    javascriptPage.JavascriptResourceManager.AddResourceHeaderScript(script);
                }
                else
                {
                    page.ClientScript.RegisterClientScriptInclude(script, scriptPath);
                }
            }
        }
示例#3
0
 public JavascriptResourceManager(JavascriptPage page)
     : this()
 {
     this.page = page;
     this.page.JavascriptResourceManager = this;
 }