internal virtual void AddAttributes() { Attributes["id"] = Id; Attributes["name"] = Name; if (!Enable) { Attributes["disabled"] = "disabled"; } if (!CssClass.IsNullOrEmpty()) { Attributes["class"] = CssClass; } if (!Validator.IsNullOrEmpty()) { Attributes["validator"] = Validator; } if (!AttributeString.IsNullOrEmpty()) { string[] kvs = AttributeString.Split(new char[] { ',', ';', '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (var kv in kvs) { string[] keyValue = kv.Split(':'); Attributes[keyValue[0]] = keyValue[1]; } } if (ChangeTiggerSearch) { Attributes["data-autotigger"] = "true"; } }
public override string Render() { if (Visiable) { TagBuilder div = new TagBuilder("div"); div.Attributes["id"] = Id; div.Attributes["widget"] = this.GetType().Name; div.Attributes["PageId"] = PageId; if (AutoHeight) { div.Attributes["data-autoHeight"] = "true"; div.Attributes["data-autoOffset"] = AutoHeightOffset.ToString(); } if (this is ITargetId) { Attributes["data-target"] = (this as ITargetId).TargetControlId; } if (!AttributeString.IsNullOrEmpty()) { string[] kvs = AttributeString.Split(new char[] { ',', ';', '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (var kv in kvs) { string[] keyValue = kv.Split(':'); Attributes[keyValue[0]] = keyValue[1]; } } foreach (var key in Attributes.Keys) { div.Attributes[key] = Attributes[key]; } if (!CssClass.IsNullOrEmpty()) { div.AddCssClass(CssClass); } try { div.InnerHtml = RenderContent(); } catch (Exception ex) { var errorTipSpan = new TagBuilder("div"); errorTipSpan.Attributes["style"] = "color:red;padding:20px;border:1px solid red;"; string stackTraceInfo = ex.StackTrace.Replace("在", "<br />在"); errorTipSpan.InnerHtml = ex.Message + stackTraceInfo; div.InnerHtml = errorTipSpan.ToString(); } return(div.ToString()); } return(string.Empty); }