/// <summary> /// Sets or removes the "disabled" attribute. /// </summary> /// <param name = "attributes">The attributes to modify.</param> /// <param name = "value">Specifies whether to set the "disabled" attribute. If set to false, this will remove the "disabled" attribute.</param> /// <returns> /// The modified <see cref = "HtmlAttributes" /> instance. /// </returns> public static HtmlAttributes Disabled( this HtmlAttributes attributes, bool value = true) { if (value) { attributes["disabled"] = "disabled"; } else { attributes.Remove("disabled"); } return(attributes); }
/// <summary> /// Adds the specified class or classes to the attributes. /// </summary> /// <param name="attributes">The attributes to which to add classes.</param> /// <param name="classes">The class or classes to be added.</param> /// <param name="include">If set to <c>true</c>, add the class; otherwise, remove it.</param> /// <returns> /// The modified <see cref="HtmlAttributes"/> instance. /// </returns> /// <remarks> /// The classes are merged with the existing classes on the <see cref="HtmlAttributes"/> instance. /// </remarks> public static HtmlAttributes Class( this HtmlAttributes attributes, string classes, bool include) { if (include) { attributes.AddCssClass(classes); } else { attributes.RemoveCssClass(classes); } return(attributes); }