面板激活时禁用背景 [英] disable background when panel active
本文介绍了面板激活时禁用背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,当面板"启用时如何禁用背景;因为我正在使用面板作为验证器
Hi,How we can disable background when ''panel'' get active; Because I am using panel as a validator
推荐答案
,如果您只想禁用页面上的所有其他控件,则可以使用以下代码
受保护的void DisableControls(控件父级)
{
foreach(parent.Controls中的控件c)
{
如果(c是DropDownList)
(((DropDownList)(c)).Enabled = false;
elseif(c是TextBox)
((TextBox)(c).Enabled = false;
//类似地,您要禁用的任何其他控件类型
DisableControls(c);
}
}
这里的parent将是您的页面名称或包含所有控件的任何其他控件
if you just want to disable every other control on page accept panel control than you can use following code
protected void DisableControls(Control parent)
{
foreach(Control c in parent.Controls)
{
if (c is DropDownList)
((DropDownList)(c)).Enabled = false;
elseif (c is TextBox)
((TextBox)(c).Enabled = false;
// similarly any other control type that you want to disable
DisableControls(c);
}
}
here parent will be your page name or any other control that holds all the controls
这篇关于面板激活时禁用背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文