您的位置:首页 > 其它

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

2006-10-03 15:00 337 查看
/article/4666452.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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐