Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Pure .NET 2.0 (No extensions! No LINQ! No RegEx! No unnecessary WebControl class!). These methods are quite general to be used not for CSS classes only.</p> <pre><code>public static string AddCssClass(string classContainer, string className) { if (string.IsNullOrEmpty(classContainer)) return className ?? string.Empty; if (string.IsNullOrEmpty(className)) return classContainer; var classNames = classContainer.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (Array.Exists(classNames, delegate(string s) { return s.Equals(className); })) return classContainer; return classContainer + " " + className; } public static string RemoveCssClass(string classContainer, string className) { if (string.IsNullOrEmpty(classContainer)) return className ?? string.Empty; if (string.IsNullOrEmpty(className)) return classContainer; var classNames = classContainer.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); int index = Array.FindIndex(classNames, delegate(string s) { return s.Equals(className); }); if (index &gt;= 0) { return string.Join(" ", classNames, 0, index) + ( index + 1 &lt; classNames.Length ? " " + string.Join(" ", classNames, index + 1, classNames.Length - index - 1) : string.Empty ); } return classContainer; } public static string ToggleCssClass(string classContainer, string className) { if (string.IsNullOrEmpty(classContainer)) return className ?? string.Empty; if (string.IsNullOrEmpty(className)) return classContainer; var classNames = classContainer.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (Array.Exists(classNames, delegate(string s) { return s.Equals(className); })) return RemoveCssClass(classContainer, className); return classContainer + " " + className; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload