I am trying to make the below function more generic. Presently, I have set it up so I can call it by passing it an HtmlInputText object and the name of the class I want to switch to. However, I'd like to configure this function to work for any object; any thoughts on how to accomplish this? Additionally, if someone has a suggestion for a better method of performing this operation I'd be interested in different solutions. Thank you!
Code:
public void switchClass(HtmlInputText textBox, string className)
{
IEnumerator keys = textBox.Attributes.Keys.GetEnumerator();
while (keys.MoveNext())
{
String key = (String)keys.Current;
if (key == "class")
textBox.Attributes[key] = className;
}
}