这个问题在论坛上的提问比较频繁的,这里总结一下几种方法,希望对没用过的朋友有所帮助^_^。
高手就不用看了
方法一:
1

#region
2
/**//// <summary>
3
/// 功能描述:遍历Asp.net窗体上所有的控件
4
/// 作者:Terrylee
5
/// 日期:2005年10月09日
6
/// </summary>
7
/// <param name="page">要设置的页面</param>
8
private void PrivilegeCheck(System.Web.UI.Control page)
9
{
10
for(int i=0;i<page.Controls.Count;i++)
11
{
12
foreach (System.Web.UI.Control control in page.Controls[i].Controls)
13
{
14
if(control is LinkButton)
15
{
16
if(true) //仅为了测试:)
17
{
18
((LinkButton)control).Enabled = false;
19
}
20
else
21
{
22
((LinkButton)control).Enabled = true;
23
}
24
}
25
else if(control is TextBox)
26
{
27
((TextBox)control).Text = "想要设置的内容";
28
}
29
else
30
{
31
//……
32
}//if
33
}//foreach
34
}//for
35
}
36
#endregion



2


3

4

5

6

7

8

9



10

11



12

13



14

15



16

17



18

19

20

21



22

23

24

25

26



27

28

29

30



31

32

33

34

35

36

稍后继续其他的:)