2012-09-12 109 views

回答

0

你可以嘗試這樣的事情

foreach (Control ctrl in Page.Controls) 
{ 
    if (c is TextBox || c is RichTextBox) 

     { 
      ///DO SOMETHING TO AVOID IT 
     } 
} 
+0

您還需要遞歸Page.Controls集合上的子控件。這並不完全正確。 – TheGeekYouNeed

0
var controls = RecursiveFunctionThatRetrievesAllAppropriateControls(Page); 

foreach(WebControl control in controls){ 
    if(control is TextBox && String.IsNullOrEmpty(((TextBox)control).Text)) 
     /* ... do something ... */ 

    ... 

}