/// <summary> /// Renders the registered attributes to the provided jStringBuilder object. The registered /// CSS classes and Style rules are also added at this point (as they're attributes as well really). /// </summary> protected internal void RenderAttributes(jStringBuilder sb) { bool hasID = _HtmlAttr.Keys.Any(x => x == "id"); // force the ID to come out first (as this is what you're interested in 90% of the time) if (hasID) { sb.AppendFormat(" id=\"{0}\"", HttpUtility.HtmlAttributeEncode(_HtmlAttr["id"].ToString()) ); } // add in any defined CSS classes if (_CssClasses.Any()) { sb.Append(" class=\""); sb.Append(this._CssClasses.ToSeparated(" ") ); sb.Append("\""); } // add in the full style rules if (_Styles.Any()) { sb.Append(" style=\""); foreach (string key in this._Styles.Keys) { sb.AppendFormat("{0}:{1};", HttpUtility.HtmlAttributeEncode(key), HttpUtility.HtmlAttributeEncode(_Styles[key].ToString()) ); } sb.TrimEnd(";"); sb.Append("\""); } if (_HtmlAttr.Any()) { // avoid ID as this will already have been added foreach (string key in _HtmlAttr.Keys.Where(x => x != "id")) { sb.AppendFormat(" {0}=\"{1}\"", key, HttpUtility.HtmlAttributeEncode(_HtmlAttr[key].ToString()) ); } } }