Exemplo n.º 1
0
 /// <summary>
 /// Displays the page by setting the lblHeader, lblMessage and lblRedirectHyperLink controls
 /// </summary>
 public void DisplayPage()
 {
     // We have to locate the various controls since the base class doesn't
     // get values assigned through class hierarchy
     DisplayPage((Label)UrlUtils.FindControlRecursive(this, "lblHeader"),
                 (Label)UrlUtils.FindControlRecursive(this, "lblMessage"),
                 (Label)UrlUtils.FindControlRecursive(this, "lblRedirectHyperLink"));
 }
Exemplo n.º 2
0
        /// <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 == ControlResources.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(ControlResources);

            if (script.ResourceControlType != null || !string.IsNullOrEmpty(script.ResourceControl))
            {
                if (script.ResourceControlType != null)
                {
                    ctlType = script.ResourceControlType;
                }
                else
                {
                    Control ctl = UrlUtils.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);
        }