예제 #1
0
        protected override void renderJQuery(JQueryUI jquery)
        {
            base.renderJQuery(jquery);

            // Generate scripts that are needed by WIDGET, each class that inherits from WidgetSetting can add needed scripts through method GetDependentScripts
            foreach (KeyValuePair <string, string> pair in this.uiSetting.GetDependentScripts( ))
            {
                string key = string.Format("__js{0}", pair.Key);

                if (!ScriptHelper.IsBuilt(new ASPXScriptHolder(this), key))
                {
                    ScriptHelper script = new ScriptHelper( );

                    script.AppendCode(pair.Value);

                    script.Build(new ASPXScriptHolder(this), key, ScriptBuildOption.Startup);
                }
            }

            for (int index = 0; index < this.uiSetting.Ajaxs.Length; index++)
            {
                AjaxSetting ajax = this.uiSetting.Ajaxs[index];

                if (!string.IsNullOrEmpty(ajax.ClientFunction))
                {
                    AjaxManager manager = this.NamingContainer.FindControl(ajax.AjaxManagerID) as AjaxManager;

                    if (null == manager)
                    {
                        throw new Exception(string.Format("没有找到 ID 为 {0} 的 AjaxManager 控件", ajax.AjaxManagerID));
                    }

                    foreach (AjaxSetting target in manager.AjaxList)
                    {
                        if (target.ClientFunction == ajax.ClientFunction)
                        {
                            if (ajax != target)
                            {
                                this.uiSetting.Ajaxs[index] = target;
                            }

                            break;
                        }
                    }
                }
            }

            // Append scripts that create the WIDGET, such as: __repeater( ... )
            jquery.Widget(this.uiSetting);
        }