.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
Post a Comment