ASP.NET 遍历设置控件的只读属性(测试过)
来源:互联网 发布:java list集合合并 编辑:程序博客网 时间:2024/05/07 13:03
for (int i = 0; i < Page.Controls.Count; i++)
{
//重点注意:System.Web.UI.Control ctr in Page.Controls[i].Controls,而不是Page.Controls
foreach (System.Web.UI.Control ctr in Page.Controls[i].Controls)
{
if (ctr is TextBox)
{
TextBox txtControl = (TextBox)ctr;
txtControl.ReadOnly = true;
txtControl.Enabled = false;
}
else if (ctr is RadioButton)
{
RadioButton btn = (RadioButton)ctr;
btn.Enabled = false;
}
else if (ctr is RadioButtonList)
{
RadioButtonList btn = (RadioButtonList)ctr;
btn.Enabled = false;
}
else if (ctr is CheckBox)
{
CheckBox cb = (CheckBox)ctr;
cb.Enabled = false;
}
else if (ctr is DropDownList)
{
DropDownList list = (DropDownList)ctr;
list.Enabled = false;
}
else if (ctr is HtmlTextArea)
{
HtmlTextArea cb = (HtmlTextArea)ctr;
cb.Attributes.Add("readonly", "");
cb.Disabled = true;
}
else if (ctr is HtmlSelect)
{
HtmlSelect rb = (HtmlSelect)ctr;
rb.Disabled = true;
}
else if (ctr is HtmlInputCheckBox)
{
HtmlInputCheckBox rb = (HtmlInputCheckBox)ctr;
rb.Disabled = true;
}
else if (ctr is HtmlInputRadioButton)
{
HtmlInputRadioButton rb = (HtmlInputRadioButton)ctr;
rb.Disabled = true;
}
else if (ctr is HtmlInputText)
{
HtmlInputControl input = (HtmlInputControl)ctr;
input.Attributes.Add("readonly", "readonly");
input.Disabled = true;
}
}
}
- ASP.NET 遍历设置控件的只读属性(测试过)
- asp.net中asp:TextBox的只读属性
- asp.net控件的遍历
- 在 ASP.NET 网页中设置控件的 HTML 属性
- asp.net 的 textbox控件怎么设置readonly属性
- asp.net服务器控件属性设置
- asp.net服务器控件属性设置
- asp.net中的服务器端控件 textbox 设为只读属性后无法获取 javascript给其赋的值
- asp.net中的服务器端控件 textbox 设为只读属性后无法获取JS给其赋的值解决办法
- textbox(asp.net 2.0)控件 只读,内容消失问题
- 设置列的只读属性
- 设置input的只读属性
- asp.net遍历控件
- ASP.NET 控件遍历
- 遍历网页中所有的控件(asp.net)
- 遍历ASP.Net页面的某个控件
- net自动化测试之道基于反射的UI自动化测试—设置控件的属性
- ASP.net中同时设置控件的多个属性,以及设置背景透明色。
- win7挽回 库 功能的注册表 用记事本编辑 保存为reg格式 导入重启即可
- [转载]saas
- DWR
- 利用Java6和BouncyCastle对文件进行加解密
- log4jdbc使用
- ASP.NET 遍历设置控件的只读属性(测试过)
- 网页嵌入字体
- Log4J配置示例,用的时候改就是了
- uname 显示当前操作系统名称
- 设置ORACLE客户端字符集
- cppunit网址
- jquery
- 这几句话,很好!!!
- SQLSERVER与ORACLE互连