foreach (Control control in table.Controls) { if (typeof control is TextBox) { // instanceof ??? ((TextBox)control).enable = false; } }自己改改吧,放时间太长了,思路应该没问题
private void SetChildControlsState(Control c , bool isDisabled) { foreach (Control cc in c.Controls) { if (cc is HtmlControl) { HtmlControl ccc = cc as HtmlControl; if (ccc != null) { ccc.Disabled = isDisabled; } } if (cc is WebControl) { WebControl ccc = cc as WebControl; if (ccc != null) { ccc.Enabled = !isDisabled; } } } }// call SetChildControlsState(yourRunatServerTableID,true);
//****遍历所有TextBox控件,同时设置TextBox Enabled属性就可以了 foreach (Control ctrl in Page.Controls) { if (ctrl is TextBox) { TextBox txt = (TextBox)ctrl; if (txt.ClientID == "txt") { txt.Enabled = false; } } }
{
if(document.getElementById("table")[i].type=="textbox")
{
document.getElementById("table")[i].disabled=true;
}
}
}
未测试~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
if(document.form1.element[i].type=="textbox")
{
document.form1.element[i].disabled=true;
}
}
}
上面的有问题~这是让整个页面上的textbox的disabled=true;根据这个改一下就可以了~~~~
if (typeof control is TextBox) { // instanceof ???
((TextBox)control).enable = false;
}
}自己改改吧,放时间太长了,思路应该没问题
table.Controls[0].GetType 这个获得的是tablerow
我给的只是个例子,具体你的控件放在那个ITEM里面,用table.items[1].Controls[0].GetType .不要认死这个代码
{
foreach (Control cc in c.Controls)
{
if (cc is HtmlControl)
{
HtmlControl ccc = cc as HtmlControl;
if (ccc != null)
{
ccc.Disabled = isDisabled;
}
}
if (cc is WebControl)
{
WebControl ccc = cc as WebControl;
if (ccc != null)
{
ccc.Enabled = !isDisabled;
}
}
}
}// call
SetChildControlsState(yourRunatServerTableID,true);
foreach (Control ctrl in Page.Controls)
{
if (ctrl is TextBox)
{
TextBox txt = (TextBox)ctrl;
if (txt.ClientID == "txt")
{
txt.Enabled = false;
}
}
}