Esempio n. 1
0
        /// <summary>
        /// 添加脚本
        /// 相同控件的脚本合并在一起([email protected] 2008-7-4)
        /// </summary>
        /// <param name="control"></param>
        /// <param name="script"></param>
        /// <param name="extraScript"></param>
        public void AddStartupScript(ControlBase control, string script, string extraScript)
        {
            ScriptBlock cs = new ScriptBlock(control, script);

            ScriptBlock existBlock = GetStartupScript(control);
            if (existBlock == null)
            {
                _startupScriptBlockList.Add(cs);
            }
            else
            {
                existBlock.Script += script;
                //existBlock.ExtraScript += extraScript;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 添加脚本
        /// 相同控件的脚本合并在一起([email protected] 2008-7-4)
        /// </summary>
        /// <param name="control"></param>
        /// <param name="script"></param>
        /// <param name="extraScript"></param>
        public void AddStartupScript(Control control, string script, string extraScript)
        {
            ScriptBlock cs = new ScriptBlock(control, script);

            //// modified by leizhang5 @2008-6-2
            //// 如果control == null, 则后添加的脚本先渲染(也就是说:子控件相关的脚本先于父控件执行)
            //if (control == null)
            //{
            //    _startupScriptBlockList.Insert(0, cs);
            //}
            //else
            //{
            ScriptBlock existBlock = GetStartupScript(control);
            if (existBlock == null)
            {
                _startupScriptBlockList.Add(cs);
            }
            else
            {
                existBlock.Script += script;
                existBlock.ExtraScript += extraScript;
            }
            //}
        }
Esempio n. 3
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            // 不渲染,此控件只作为中间转化层
            RenderWrapperNode = false;
            AddStartupScript(String.Empty);

            // 一个UserControlConnector里面可能放多个UserControl,
            // 每个UserControl中的所有直接子节点都不要即时渲染
            StringBuilder sb = new StringBuilder();

            foreach (Control userControl in Controls)
            {
                if (userControl is UserControl)
                {
                    // 用户控件中的FineUI控件(x1,x4,x6)
                    sb.AppendFormat("{0},", GetControlIds(userControl.Controls));

                    // 用户控件里面的都不要即时渲染
                    foreach (Control c in userControl.Controls)
                    {
                        ControlBase childControl = c as ControlBase;
                        if (childControl != null)
                        {
                            childControl.RenderWrapperNode = false;
                        }
                    }
                }
            }

            // 重新设置父节点的注册脚本
            ControlBase parentControl = Parent as ControlBase;

            if (parentControl != null)
            {
                ScriptBlock cs = ResourceManager.Instance.GetStartupScript(parentControl);
                cs.Script = GetResolveScript(cs.Script, sb.ToString().TrimEnd(','));
            }


            //// 目前只处理第一个子控件,其他的舍弃
            //UserControl userControl = GetFirstChildUserControl(Controls);
            //if (userControl != null)
            //{
            //    // 用户控件里面的都不要即时渲染
            //    foreach (Control c in userControl.Controls)
            //    {
            //        ControlBase childControl = c as ControlBase;
            //        if (childControl != null)
            //        {
            //            childControl.RenderWrapperNode = false;
            //        }
            //    }


            //    // 重新设置父节点的注册脚本
            //    ControlBase parentControl = Parent as ControlBase;
            //    if (parentControl != null)
            //    {
            //        ScriptBlock cs = ResourceManager.Instance.GetStartupScript(parentControl);
            //        cs.Script = GetResolveScript(cs.Script, GetControlIds(userControl.Controls));
            //    }
            //}
        }