RT,比如说我一个table里面用了很多TextBox和Label的控件,它们都要统一的长度和显示ToolTip,
我不想一个一个地改,想在后台用C#来实现,
有没有方法一次性抓取到所有的TextBox和Label, 
请大家指教

解决方案 »

  1.   

    foreach (Control ctl in this.Controls)
            {
                if (ctl.GetType().ToString() == "System.Web.UI.WebControls.TextBox")
                {
                    TextBox txt = (TextBox)ctl;
                    txt.Width = "要设置的宽度";
                }
                else if (ctl.GetType().ToString() == "System.Web.UI.WebControls.Label")
                {
                    Label lbl = (Label)ctl;
                    lbl.ToolTip = "要设置的提示";
                }        }