Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
alpoor
Starting Member
29 Posts |
Posted - 2005-06-14 : 18:00:59
|
I need to retrieve all controls in a webform. Once I get reference to all controls, I have to make them either editable or noneditable depending upon the user who logged on to that pageAny ideas will be appreciatedThanks |
|
saglamtimur
Yak Posting Veteran
91 Posts |
Posted - 2005-06-14 : 18:55:14
|
Dim cntrl As Control Dim childc As Control For Each cntrl In Page.Controls 'This will find Form1 cus its the first control on page and holds other controls Response.Write(cntrl.ID) For Each childc In cntrl.Controls 'this will fine all other controls in Form1 Response.Write(childc.ID) Next NextYou must modify this code for your page structure. For example if you put a panel control and a button control inside this panel, this code will not show that button's id. This is like a tree structure. It ll show all controls ids (including panel) which is under Form1 but not button control cus its on a panel control. And same thing applies to datagrids etc which can hold other controls. One solution can be adding some -if- statemnts just after second -For- to check if form has controls which can hold controls.If TypeOf childc Is Panel Then'another for next loop here to find ids on panel control(s) (or whatever you want)Hope this gives some idea.Regards |
 |
|
alpoor
Starting Member
29 Posts |
Posted - 2005-06-15 : 11:48:22
|
It worked like champ. You the MANThanks againquote: Originally posted by saglamtimur Dim cntrl As Control Dim childc As Control For Each cntrl In Page.Controls 'This will find Form1 cus its the first control on page and holds other controls Response.Write(cntrl.ID) For Each childc In cntrl.Controls 'this will fine all other controls in Form1 Response.Write(childc.ID) Next NextYou must modify this code for your page structure. For example if you put a panel control and a button control inside this panel, this code will not show that button's id. This is like a tree structure. It ll show all controls ids (including panel) which is under Form1 but not button control cus its on a panel control. And same thing applies to datagrids etc which can hold other controls. One solution can be adding some -if- statemnts just after second -For- to check if form has controls which can hold controls.If TypeOf childc Is Panel Then'another for next loop here to find ids on panel control(s) (or whatever you want)Hope this gives some idea.Regards
|
 |
|
|
|
|