I want to edit/modify the CSS class for an existing TagBuilder.
Currently the Tag is:
div.Attributes.Add("class", "checkbox");
I want to change it to below, after the previous statement already executed.
div.Attributes.Add("class", "book");
How would I conduct this? Currently I have to Delete/Remove Attribute, and Readd. Just curious if there is more efficient way.
checkbox.Attributes.Remove("class");
checkbox.MergeAttribute("class", "book");
Use the
MergeAttributeoverload accepting a boolean to overwrite the existing value.From the documentation