public static void Redirect(string url, string msg, string msgCls)
        {
            ResourceManager rm = ResponseManager.ResourceManager;

            if (rm == null)
            {
                throw new InvalidOperationException("The ResourceManager could not be found during the Ext.Redirect.");
            }

            if (url.IsEmpty())
            {
                throw new ArgumentNullException("url", "The redirection url is empty");
            }

            if (msg.IsNotEmpty())
            {
                X.Mask.Show(new MaskConfig
                {
                    Msg    = msg,
                    MsgCls = msgCls
                });
            }

            rm.AddScript("window.location=\"".ConcatWith(TokenUtils.IsRawToken(url) ? url : rm.ResolveClientUrl(url), "\";"));
        }
Example #2
0
        protected static void RegisterTriggerIcon(TriggerIcon icon)
        {
            if (icon == TriggerIcon.Combo ||
                icon == TriggerIcon.Clear ||
                icon == TriggerIcon.Date ||
                icon == TriggerIcon.Search ||
                HttpContext.Current == null)
            {
                return;
            }

            ResourceManager rm = ResourceManager.GetInstance(HttpContext.Current);

            if (rm == null)
            {
                return;
            }

            string iconName = icon.ToString();
            string key      = "x-form-".ConcatWith(iconName.ToLower(), "-trigger");

            if (rm.IsClientStyleBlockRegistered(key))
            {
                return;
            }

            string urlName = iconName.ToCharacterSeparatedFileName('-', "gif");

            if (rm.Theme != Theme.Default && (icon == Net.TriggerIcon.Ellipsis || icon == Net.TriggerIcon.Empty))
            {
                urlName = string.Concat(rm.Theme.ToString().ToLowerInvariant(), ".", urlName);
            }

            string url  = rm.GetWebResourceUrl(string.Format(ResourceManager.ASSEMBLYSLUG + ".ux.extensions.triggerfield.images.{0}", urlName));
            string url1 = "";
            string css  = ".x-form-field-wrap .{0}{{background-image:url({1});cursor:pointer;}}";

            if (!RequestManager.IsWebKit && iconName.StartsWith("Simple"))
            {
                url1 = rm.GetWebResourceUrl(string.Format(ResourceManager.ASSEMBLYSLUG + ".ux.extensions.triggerfield.images.{0}", iconName.ToCharacterSeparatedFileName('-', "").ConcatWith("-small.gif")));
                css += " .x-small-editor .x-form-field-wrap .{0}{{background-image:url({2});cursor:pointer;}}";
            }

            if (Ext.Net.X.IsAjaxRequest)
            {
                //CSS.CreateStyleSheet(css.FormatWith(key, url, url1), key);
                rm.AddScript("Ext.net.ResourceMgr.registerCssClass({0}, {1});", JSON.Serialize(key), JSON.Serialize(css.FormatWith(key, url, url1)));
            }
            else
            {
                rm.RegisterClientStyleBlock(key, css.FormatWith(key, url, url1));
            }
        }
        private static void RegisterScript(string name, params object[] arguments)
        {
            ResourceManager rm     = ResourceManager.GetInstance(HttpContext.Current);
            string          script = "Ext.core.DomHelper.".ConcatWith(name, "(", FormatArgs(arguments), ");");

            if (rm != null)
            {
                rm.AddScript(script);
                return;
            }

            ResourceManager.AddInstanceScript(script);
        }
Example #4
0
        protected virtual void RenderScript(string script)
        {
            ResourceManager rm = ResourceManager.GetInstance(HttpContext.Current);

            if (HttpContext.Current.CurrentHandler is Page && rm != null)
            {
                rm.AddScript(script);
            }
            else
            {
                new DirectResponse(script).Return();
            }
        }
        public static void Render(UserControlRendrerConfig config)
        {
            ResourceManager rm = ResourceManager.GetInstance(HttpContext.Current);

            var script = UserControlRenderer.ToScript(config);

            if (HttpContext.Current.CurrentHandler is Page && rm != null)
            {
                rm.AddScript(script);
            }
            else
            {
                new DirectResponse(script).Return();
            }
        }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="script"></param>
        protected virtual void RenderScript(string script)
        {
            if (HttpContext.Current == null)
            {
                return;
            }

            ResourceManager rm = ResourceManager.GetInstance(HttpContext.Current);

            if (HttpContext.Current.CurrentHandler is Page && rm != null)
            {
                rm.AddScript(script);
            }
            else
            {
                ResourceManager.AddInstanceScript(script);
            }
        }
        public virtual void AddScript(string script)
        {
            if (this.IsProxy || this.AlreadyRendered)
            {
                if (HttpContext.Current == null)
                {
                    ResourceManager.AddInstanceScript(script);
                    return;
                }

                ResourceManager rm = ResourceManager.GetInstance(HttpContext.Current);

                if (HttpContext.Current.CurrentHandler is Page && rm != null)
                {
                    rm.AddScript(script);
                }
                else
                {
                    ResourceManager.AddInstanceScript(script);
                }

                return;
            }

            if (script.IsNotEmpty() && !this.IsParentDeferredRender && this.Visible)
            {
                if (this.AlreadyRendered && this.HasResourceManager)
                {
                    this.ResourceManager.RegisterOnReadyScript(ResourceManager.ScriptOrderNumber, TokenUtils.ReplaceRawToken(TokenUtils.ParseTokens(script, this)));
                }
                else
                {
                    this.ProxyScripts.Add(ResourceManager.ScriptOrderNumber, TokenUtils.ReplaceRawToken(TokenUtils.ParseTokens(script, this)));
                }
            }
        }