.net - Enumerate all controls in the form -


private void enablecontrols(bool enable)         {             foreach (textbox t in page.form.controls.oftype<textbox>())             {                 t.readonly = !enable;             }             chksameascurrent.enabled = enable;         } 

the above code runs fine in simple page not having master page, if run in contentpage can not enumerate textboxes , not control in form.

try this. think should work.

 private void recursiveloopthroughcontrols(control root)  {       foreach (control control in root.controls)       {           recursiveloopthroughcontrols(control);           //process control.       }  } 

call method using

 recursiveloopthroughcontrols(page) 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -