/// <summary> /// Code that embeds related resources (.js and css) /// </summary> /// <param name="scriptProxy"></param> protected void RegisterResources(ClientScriptProxy scriptProxy) { scriptProxy.LoadControlScript(this, jQueryJs, WebResources.JQUERY_SCRIPT_RESOURCE, ScriptRenderModes.HeaderTop); scriptProxy.RegisterClientScriptInclude(Page, typeof(WebResources), CalendarJs, ScriptRenderModes.Header); string cssPath = CalendarCss; if (!string.IsNullOrEmpty(Theme)) { cssPath = cssPath.Replace("/base/", "/" + Theme + "/"); } scriptProxy.RegisterCssLink(Page, typeof(WebResources), cssPath, cssPath); }
/// <summary> /// Registers an individual script item in the page /// </summary> /// <param name="script"></param> private void RegisterScriptItem(ScriptItem script) { // Allow inheriting from control which is the default behavior if (script.RenderMode == ScriptRenderModes.Inherit) { script.RenderMode = RenderMode; } // Skip over inline scripts if (script.RenderMode == ScriptRenderModes.Inline) { return; } // special case jquery load from Content network if (ScriptLoader.jQueryLoadMode == jQueryLoadModes.ContentDeliveryNetwork && script.Resource == WebResources.JQUERY_SCRIPT_RESOURCE || script.Resource == "jquery" || script.Resource == "jquery.js" || script.Src.ToLower().Contains("/jquery.js")) { ScriptLoader.LoadjQuery(Page); return; } // special case jquery-uiload from Content network if (script.Src.ToLower().Contains("/jquery-ui.") || script.Resource == "jqueryui" || script.Resource == "jquery-ui") { ScriptLoader.LoadjQueryUi(Page, null); return; } string src = string.Empty; Type ctlType = typeof(WebResources); if (script.ResourceControlType != null || !string.IsNullOrEmpty(script.ResourceControl)) { if (script.ResourceControlType != null) { ctlType = script.ResourceControlType; } else { Control ctl = WebUtils.FindControlRecursive(Page, script.ResourceControl, false); if (ctl != null) { ctlType = ctl.GetType(); } else { throw new ArgumentException("Invalid Web Control passed for resource retrieval. Please pass a control from the assembly where the resource are located."); } } src = scriptProxy.GetClientScriptResourceUrl(Page, ctlType, script.Resource); } else if (!string.IsNullOrEmpty(script.Resource)) { src = scriptProxy.GetClientScriptResourceUrl(this, ctlType, script.Resource); } else { src = ResolveUrl(script.Src); // Fix up the URL so we can allow ~/script syntax if (script.AllowMinScript && !HttpContext.Current.IsDebuggingEnabled) { src = src.ToLower().Replace(".js", MinScriptExtension); } } // if there's a version number implied add a par if (!string.IsNullOrEmpty(script.Version)) { if (src.Contains("?")) { src += "&ver=" + script.Version; } else { src += "?ver=" + script.Version; } } scriptProxy.RegisterClientScriptInclude(Page, ctlType, src, script.RenderMode); }