本文整理汇总了C#中System.Web.UI.WebControls.Panel.HasControls方法的典型用法代码示例。如果您正苦于以下问题:C# Panel.HasControls方法的具体用法?C# Panel.HasControls怎么用?C# Panel.HasControls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.Panel
的用法示例。
在下文中一共展示了Panel.HasControls方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnableAndDisableAllControls
/// <summary>
/// Enables the and disable all controls.
/// </summary>
/// <param name="panel">The panel.</param>
/// <param name="enable">if set to <c>true</c> [enable].</param>
public static void EnableAndDisableAllControls(Panel panel, bool enable)
{
if (!panel.HasControls())
{
return;
}
foreach (Control ct in panel.Controls)
{
if (ct.GetType() == typeof(TextBox))
{
TextBox control = (TextBox)ct;
control.Enabled = enable;
}
if (ct.GetType() == typeof(RadioButtonList))
{
RadioButtonList control = (RadioButtonList)ct;
control.Enabled = enable;
}
if (ct.GetType() == typeof(RadioButton))
{
RadioButton control = (RadioButton)ct;
control.Enabled = enable;
}
if (ct.GetType() == typeof(DropDownList))
{
DropDownList control = (DropDownList)ct;
control.Enabled = enable;
}
}
}
示例2: ClearAllControls
/// <summary>
/// Clears all controls.
/// </summary>
/// <param name="panel">The panel.</param>
public static void ClearAllControls(Panel panel)
{
if (!panel.HasControls())
{
return;
}
foreach (Control ct in panel.Controls)
{
if (ct.GetType() == typeof(TextBox))
{
TextBox control = (TextBox)ct;
control.Text = string.Empty;
}
if (ct.GetType() == typeof(DropDownList))
{
DropDownList control = (DropDownList)ct;
control.ClearSelection();
}
if (ct.GetType() == typeof(RadioButtonList))
{
RadioButtonList control = (RadioButtonList)ct;
control.ClearSelection();
}
}
}