1.System.Web.UI.Control类型
遍历控件
代码
string theInfo = String.Empty;
theInfo = string.Format("Has controls? {0} <br/>", myPanel.HasControls());
foreach (Control c in myPanel.Controls)
{
if (!object.ReferenceEquals(c.GetType(), typeof(System.Web.UI.LiteralControl)))
{
theInfo += "***************************<br/>";
theInfo += string.Format("Control Name? {0} <br/>", c.ToString());
theInfo += string.Format("ID? {0} <br>", c.ID);
theInfo += string.Format("Control Visible? {0} <br/>", c.Visible);
theInfo += string.Format("ViewState? {0} <br/>", c.EnableViewState);
}
}
lblControlInfo.Text = theInfo;
动态添加控件
代码
for (int i = 0; i < 3; i++)
{
// Assign a name so we can get
// the text value out later
// using the incoming form data.
TextBox t = new TextBox();
t.ID = string.Format("newTextBox{0}", i);
myPanel.Controls.Add(t);
}
2.ASP.NET Web空间的类别
*简单控件
*(功能)富控件
*以数据为中心的控件
*输入验证控件
*Web部件控件
*安全控件