Exemple #1
0
        public T ClassName(string className)
        {
            var list = ElementClassNames.ToList();

            list.Add(className);

            ElementClassNames = list;

            return((T)this);
        }
Exemple #2
0
        /// <summary>
        /// Combines the attributes, id and classnames into an HTML string.
        /// </summary>
        public virtual string FormatAttributes()
        {
            var attributes = ElementAttributes
                             .Guard()
                             .ChainSet("id", ElementId)
                             .ChainSet("class", string.Join(" ", ElementClassNames.Guard()))
                             .Where(kvp => !string.IsNullOrEmpty(kvp.Value))
                             .Select(kvp => $"{EscapeString(kvp.Key)}=\"{EscapeString(kvp.Value)}\"");

            return(string.Join(" ", attributes));
        }