如果历遍webform中的所有控件?
我下面的代码不行,请指教。
for (int i = 0; i < this.Controls.Count; i ++)
{
//TO DO: the following lines don't work!
if (this.Controls[i] is TextBox)
if (!(Controls[i] as TextBox).ReadOnly)
(Controls[i] as TextBox) .Text = string.Empty;
else if (this.Controls[i] is DropDownList)
if ((Controls[i] as DropDownList).Enabled)
(Controls[i] as DropDownList).SelectedIndex = 0;
}