/// <summary> /// 重新构造. /// </summary> public override void Recombine( ) { base.Recombine( ); foreach (AjaxSetting ajax in this.ajaxs) { if (ajax.EventType != EventType.none && ajax.EventType != EventType.__init) { OptionType optionType; try { optionType = ( OptionType )Enum.Parse(typeof(OptionType), ajax.EventType.ToString( ), true); } catch { continue; } if (!string.IsNullOrEmpty(ajax.ClientFunction)) { this.settingHelper.SetOptionValue(optionType, ajax.ClientFunction, string.Empty); continue; } //!+ The following code is similar with AutocompleteSetting.Recombine if (ajax.Data.StartsWith("e.")) { if (string.IsNullOrEmpty(ajax.MethodName)) { ajax.Data = string.Format("jQuery.extend({0}, {1})", "{}", ajax.Data); } else { ajax.Data = string.Format("jQuery.panzer.encodeData({0})", ajax.Data); } } JQuery jquery = JQueryUI.Create(ajax); if (null != jquery) { jquery.EndLine( ); this.settingHelper.SetOptionValue(optionType, "function(pe, e) {" + jquery.Code + "}", string.Empty); } } } }
protected override void Render(HtmlTextWriter writer) { if (!this.Visible) { return; } if (this.isFaceless( )) { writer.Write("<span style=\"font-family: Verdana; background-color: #FFFFFF; font-size: 10pt;\"><strong>{0}:</strong> {1}</span>", "AjaxManager", this.ID); } if (this.DesignMode) { return; } ScriptHelper script = new ScriptHelper( ); //!+ The following code is similar with AutocompleteSetting.Recombine, WidgetSetting.Recombine foreach (AjaxSetting ajax in this.ajaxs) { if (!string.IsNullOrEmpty(ajax.ClientFunction)) { string data; if (string.IsNullOrEmpty(ajax.MethodName)) { data = "data"; } else // According to the .NET version to determine the location of JSON if (Environment.Version.Major <= 2 || (Environment.Version.Major == 3 && Environment.Version.Minor == 0)) { data = "data"; } else { data = "data.d"; } if (!string.IsNullOrEmpty(ajax.Success)) { ajax.Success = ajax.Success.Replace("-:data", data); } if (!string.IsNullOrEmpty(ajax.Complete)) { ajax.Complete = ajax.Complete.Replace("-:data", data); } if (!string.IsNullOrEmpty(ajax.Error)) { ajax.Error = ajax.Error.Replace("-:data", data); } JQuery jquery = JQueryUI.Create(ajax); if (null != jquery) { script.AppendCode("function " + ajax.ClientFunction + "(" + ajax.ClientParameter + ") {" + jquery.Code + "}"); } } } script.Build(new ASPXScriptHolder(this), this.ClientID, ScriptBuildOption.Startup); }