Esempio n. 1
0
        public static string ReplaceIDTokens(string script, Control seed)
        {
            script = TokenUtils.ReplaceAjaxMethods(script, seed);
            script = TokenUtils.ReplaceFuncToken(script);

            Regex           regex   = new Regex(TokenUtils.ID_PATTERN);
            MatchCollection matches = regex.Matches(script);
            Control         control = null;
            string          id      = "";

            foreach (Match match in matches)
            {
                id = match.Value.Remove(match.Value.Length - 1).Remove(0, 2);

                control = ControlUtils.FindControl(seed, id);

                if (control != null)
                {
                    if (control is Layout)
                    {
                        Component component = ((Layout)control).ParentComponent;
                        script = script.Replace(match.Value, component != null ? string.Concat(component.ClientID, ".getLayout()") : control.ClientID);
                    }
                    else if (control is Observable || control is UserControl)
                    {
                        script = script.Replace(match.Value, control.ClientID);
                    }
                    else
                    {
                        script = script.Replace(match.Value, string.Concat("Ext.get(\"", control.ClientID, "\")"));
                    }
                }
                else
                {
                    script = script.Replace(match.Value, string.Concat("Ext.get(\"", match.Value.Remove(match.Value.Length - 1).Remove(0, 2), "\")"));
                }
            }

            return(script);
        }