62,046
社区成员
发帖
与我相关
我的任务
分享
if (txt != null)
{
flag++;
//这里你可以取值赋值
}
protected int flag = 0;
protected void Page_Load(object sender, EventArgs e)
{
GetTextBox(Page);
Response.Write(flag.ToString()+" 个");
}
private void GetTextBox(Control c)
{
if (c.Controls.Count > 0)
{
for (int i = 0; i < c.Controls.Count; i++)
{
GetTextBox(c.Controls[i]);
}
}
HtmlInputText txt = c as HtmlInputText;
if (txt != null)
{
flag++;
}
}