C#2008与.NET 3.5 高级程序设计读书笔记(32)-- ASP.NET Web控件、主题和母版页
1.System.Web.UI.Control类型
遍历控件
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
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;
动态添加控件
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
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部件控件
*安全控件