前台界面:
后台代码:
1
using System;
2
using System.Collections;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Web;
7
using System.Web.SessionState;
8
using System.Web.UI;
9
using System.Web.UI.WebControls;
10
using System.Web.UI.HtmlControls;
11![](/Images/OutliningIndicators/None.gif)
12
namespace AspNetTest.Common
13
{
14
/// <summary>
15
/// MoreControls 的摘要说明。
16
/// </summary>
17
public class Controls : System.Web.UI.Page
18
{
19
protected System.Web.UI.WebControls.Panel Panel1;
20
protected System.Web.UI.WebControls.Panel Panel2;
21
protected System.Web.UI.WebControls.TextBox TextBox2;
22
protected System.Web.UI.WebControls.Label Label1;
23
protected System.Web.UI.WebControls.Button Button1;
24
protected System.Web.UI.WebControls.Label Label2;
25
protected System.Web.UI.WebControls.TextBox TextBox3;
26
protected System.Web.UI.WebControls.Button Button2;
27
protected System.Web.UI.WebControls.TextBox TextBox1;
28
29
private bool bFound = false;
30
private void Page_Load(object sender, System.EventArgs e)
31
{
32
// 在此处放置用户代码以初始化页面
33
}
34![](/Images/OutliningIndicators/InBlock.gif)
35
Web 窗体设计器生成的代码
57![](/Images/OutliningIndicators/InBlock.gif)
58
private void Button1_Click(object sender, System.EventArgs e)
59
{
60
GetTextBoxValues(Panel1);
61
}
62
private void GetTextBoxValues(Control c)
63
{
64
if(c is TextBox)
65
{
66
Label1.Text += c.ID + " 的值:" + ((TextBox)c).Text + "<br>";
67
}
68
else
69
{
70
for(int i=0; i<c.Controls.Count; i++)
71
{
72
GetTextBoxValues(c.Controls[i]);
73
}
74
}
75
}
76
private void SearchTextBoxValue(Control c, string SearchId)
77
{
78
if(c is TextBox)
79
{
80
if(c.ID == SearchId)
81
{
82
Label1.Text = c.ID + " 的值:" + ((TextBox)c).Text + "<br>";
83
bFound = true;
84
}
85
}
86
else
87
{
88
for(int i=0; i<c.Controls.Count; i++)
89
{
90
SearchTextBoxValue(c.Controls[i], SearchId);
91
}
92
}
93
}
94![](/Images/OutliningIndicators/InBlock.gif)
95
private void Button2_Click(object sender, System.EventArgs e)
96
{
97
string SearchTextBoxId = TextBox3.Text.Trim();
98
SearchTextBoxValue(Panel1, SearchTextBoxId);
99
if(bFound == false)
100
{
101
Label1.Text = "<font color=red>没有找到ID值为 " + SearchTextBoxId + "的文本框</font>";
102
}
103
}
104
}
105
}
106![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/None.gif)
12
![](/Images/OutliningIndicators/None.gif)
13
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
14
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/InBlock.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
57
![](/Images/OutliningIndicators/InBlock.gif)
58
![](/Images/OutliningIndicators/InBlock.gif)
59
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
60
![](/Images/OutliningIndicators/InBlock.gif)
61
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
62
![](/Images/OutliningIndicators/InBlock.gif)
63
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
64
![](/Images/OutliningIndicators/InBlock.gif)
65
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
66
![](/Images/OutliningIndicators/InBlock.gif)
67
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
68
![](/Images/OutliningIndicators/InBlock.gif)
69
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
70
![](/Images/OutliningIndicators/InBlock.gif)
71
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
72
![](/Images/OutliningIndicators/InBlock.gif)
73
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
74
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
75
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
76
![](/Images/OutliningIndicators/InBlock.gif)
77
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
78
![](/Images/OutliningIndicators/InBlock.gif)
79
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
80
![](/Images/OutliningIndicators/InBlock.gif)
81
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
82
![](/Images/OutliningIndicators/InBlock.gif)
83
![](/Images/OutliningIndicators/InBlock.gif)
84
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
85
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
86
![](/Images/OutliningIndicators/InBlock.gif)
87
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
88
![](/Images/OutliningIndicators/InBlock.gif)
89
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
90
![](/Images/OutliningIndicators/InBlock.gif)
91
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
92
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
93
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
94
![](/Images/OutliningIndicators/InBlock.gif)
95
![](/Images/OutliningIndicators/InBlock.gif)
96
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
97
![](/Images/OutliningIndicators/InBlock.gif)
98
![](/Images/OutliningIndicators/InBlock.gif)
99
![](/Images/OutliningIndicators/InBlock.gif)
100
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
101
![](/Images/OutliningIndicators/InBlock.gif)
102
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
103
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
104
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
105
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
106
![](/Images/OutliningIndicators/None.gif)
效果图1:
效果图2: