internal virtual string Build(string template, params object[] args) { if (this.sm == null) { this.sm = ScriptManager.GetInstance(HttpContext.Current); } if (this.page == null && this.sm != null) { this.page = this.sm.Page; } for (int i = 0; i < args.Length; i++) { if (args[i] is string) { args[i] = TokenUtils.ParseAndNormalize(args[i].ToString(), this.sm); } } return(string.Format(template, args)); }
public void GenerateProxy(StringBuilder sb, string controlID) { sb.Append(this.Name); sb.Append(":function("); foreach (ParameterInfo parameterInfo in this.Params) { sb.Append(parameterInfo.Name); sb.Append(","); } sb.Append("config"); sb.Append("){"); sb.Append("Coolite.AjaxMethod.request(\""); sb.Append(this.Name); sb.Append("\",Ext.apply(config || {}, {"); int index = 0; bool needComma = false; if (this.Params.Length > 0) { sb.Append("params:{"); foreach (ParameterInfo parameterInfo in this.Params) { sb.Append(parameterInfo.Name); sb.Append(":"); sb.AppendFormat(parameterInfo.Name); index++; if (index < this.Params.Length) { sb.Append(","); } } sb.Append("}"); needComma = true; } if (this.Method.IsStatic) { sb.Append(needComma ? "," : ""); sb.Append("specifier:\"static\""); needComma = true; } if (!string.IsNullOrEmpty(controlID)) { sb.Append(needComma ? "," : ""); sb.AppendFormat("control:\"{0}\"", controlID); needComma = true; } if (this.Attribute.Method == HttpMethod.GET) { sb.Append(needComma ? "," : ""); sb.Append("method:\"GET\""); needComma = true; } if (this.Attribute.ShowMask) { sb.Append(needComma ? "," : ""); sb.Append("eventMask:{showMask:true"); if (!string.IsNullOrEmpty(this.Attribute.Msg)) { sb.Append(",msg:").Append(JSON.Serialize(this.Attribute.Msg)); } if (!string.IsNullOrEmpty(this.Attribute.MsgCls)) { sb.Append(",msgCls:").Append(JSON.Serialize(this.Attribute.MsgCls)); } if (!string.IsNullOrEmpty(this.Attribute.CustomTarget)) { this.Attribute.Target = MaskTarget.CustomTarget; } if (this.Attribute.Target != MaskTarget.Page) { sb.Append(",target:").Append(JSON.Serialize(this.Attribute.Target.ToString().ToLower())); } if (this.Attribute.Target == MaskTarget.CustomTarget && !string.IsNullOrEmpty(this.Attribute.CustomTarget)) { ScriptManager sm = null; if (HttpContext.Current != null) { sm = ScriptManager.GetInstance(HttpContext.Current); } string script = TokenUtils.ReplaceRawToken((sm != null) ? TokenUtils.ParseTokens(this.Attribute.CustomTarget, sm) : TokenUtils.ParseAndNormalize(this.Attribute.CustomTarget)); sb.Append(",customTarget:").Append(script); //sb.Append(",customTarget:").Append(JSON.Serialize(this.Attribute.CustomTarget)); } sb.Append("}"); needComma = true; } if (this.Attribute.Type == AjaxEventType.Load) { sb.Append(needComma ? "," : ""); sb.Append("type:\"load\""); needComma = true; } if (this.Attribute.ViewStateMode != ViewStateMode.Default) { sb.Append(needComma ? "," : ""); sb.AppendFormat("viewStateMode:\"{0}\"", this.Attribute.ViewStateMode.ToString().ToLowerInvariant()); needComma = true; } if (this.Attribute.Timeout != 30000) { sb.Append(needComma ? "," : ""); sb.AppendFormat("timeout:{0}", this.Attribute.Timeout); needComma = true; } if (!string.IsNullOrEmpty(this.Attribute.SuccessFn)) { sb.Append(needComma ? "," : ""); sb.AppendFormat("success:{0}", this.Attribute.SuccessFn); needComma = true; } if (!string.IsNullOrEmpty(this.Attribute.FailureFn)) { sb.Append(needComma ? "," : ""); sb.AppendFormat("failure:{0}", this.Attribute.FailureFn); } sb.Append("}));}"); }
public virtual void AddListener(string eventName, string handler, string scope, HandlerConfig options) { string template = "{0}.on(\"{1}\",{2},{3},{4});"; this.AddScript(template, this.ClientID, eventName, TokenUtils.ParseAndNormalize(handler, this), scope, options.ToJsonString()); }
public static string ParseAndNormalize(string script) { return(TokenUtils.ParseAndNormalize(script, null)); }
public virtual void AddListener(string eventName, string handler, string scope) { string template = "{0}.on(\"{1}\",{2},{3});"; this.AddScript(template, this.ClientID, eventName.ToLower(), TokenUtils.ParseAndNormalize(handler, this), scope); }