用表单字段加亮的方式为用户提供友好的界面

http://www.cnblogs.com/aspnetx/archive/2006/10/01/519873.html

其实很简单,在微软的一个例子中早就有了
public static void SetInputControlsHighlight(Control container, string className, bool onlyTextBoxes)//将指定的样式应用于页面控件
{
foreach (Control ctl in container.Controls)//与
{
if ((onlyTextBoxes && ctl is TextBox) || ctl is TextBox || ctl is DropDownList ||
ctl is ListBox || ctl is CheckBox || ctl is RadioButton ||
ctl is RadioButtonList || ctl is CheckBoxList)
{
WebControl wctl = ctl as WebControl;
wctl.Attributes.Add("onmouseover", string.Format("this.className = '{0}';", className));
wctl.Attributes.Add("onmouseout", "this.className = '';");
}
else
{
if (ctl.Controls.Count > 0)
SetInputControlsHighlight(ctl, className, onlyTextBoxes);
}
}
}

在page_load()中调用该函数
如 SetInputControlsHighlight(this, className, true);
原文地址:https://www.cnblogs.com/flyfish/p/520574.html