473,661 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

easier way to collect controls on a page?

My goal is to collect all the textboxes on a given page in code (or all
checkboxes).

The only way that I know how is traversing through the hierarchy and collect
them

Page
|__Controls
|____HtmlForm
|__text boxes found here

The trouble is controls are embedded in others such as user controls, panel,
table, datagrid, etc, in which case, I'd have to look in there to find them
and there is no way I can write code to cover every possible hierarchy and
chase them down. Is there a cleaner way of doing this? I suppose I can
write a recursive function to do this.

If on a given web form, I want to collect all textboxes. As simple as that,
but hierarchies can be pretty complex.
Nov 18 '05 #1
3 1041
Jos
"David" <sp************ @spammersgohome .com> wrote in message
news:4F******** ***********@twi ster.socal.rr.c om...
My goal is to collect all the textboxes on a given page in code (or all
checkboxes).

The only way that I know how is traversing through the hierarchy and collect them

Page
|__Controls
|____HtmlForm
|__text boxes found here

The trouble is controls are embedded in others such as user controls, panel, table, datagrid, etc, in which case, I'd have to look in there to find them and there is no way I can write code to cover every possible hierarchy and
chase them down. Is there a cleaner way of doing this? I suppose I can
write a recursive function to do this.

If on a given web form, I want to collect all textboxes. As simple as that, but hierarchies can be pretty complex.


A recursive function is the way to go (VB.NET):

Sub DoControls(ctl As Control)
If(TypeOf ctl Is TextBox) Then
' do your stuff here
End If
Dim myControl As Control
For Each myControl In ctl.Controls
DoControls(myCo ntrol)
Next
End Sub

--

Jos
Nov 18 '05 #2
"David" <sp************ @spammersgohome .com> wrote in message
news:4F******** ***********@twi ster.socal.rr.c om...
My goal is to collect all the textboxes on a given page in code (or all
checkboxes).

The only way that I know how is traversing through the hierarchy and collect them

Page
|__Controls
|____HtmlForm
|__text boxes found here

The trouble is controls are embedded in others such as user controls, panel, table, datagrid, etc, in which case, I'd have to look in there to find them and there is no way I can write code to cover every possible hierarchy and
chase them down. Is there a cleaner way of doing this? I suppose I can
write a recursive function to do this.

If on a given web form, I want to collect all textboxes. As simple as that, but hierarchies can be pretty complex.


What happens in the future when you change one of the TextBox controls into
a RichTextBox control or some other control?

One awkward way to do this would be to store references to all of the
controls in an array at runtime:

Dim ca As New Control(){txtBo x1, txtBox2, rtxBox3}

--
John Saunders
johnwsaundersii i at hotmail
Nov 18 '05 #3
Check out this article, this will help you,
http://www.extremeexperts.com/Net/Ar...hControls.aspx

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com

"David" <sp************ @spammersgohome .com> wrote in message
news:4F******** ***********@twi ster.socal.rr.c om...
My goal is to collect all the textboxes on a given page in code (or all
checkboxes).

The only way that I know how is traversing through the hierarchy and collect them

Page
|__Controls
|____HtmlForm
|__text boxes found here

The trouble is controls are embedded in others such as user controls, panel, table, datagrid, etc, in which case, I'd have to look in there to find them and there is no way I can write code to cover every possible hierarchy and
chase them down. Is there a cleaner way of doing this? I suppose I can
write a recursive function to do this.

If on a given web form, I want to collect all textboxes. As simple as that, but hierarchies can be pretty complex.

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1564
by: Michael | last post by:
Hi All, I am working on my intranet reporting web site, by use of IIS5 + Office2000 +SQL2000. Currently, the first step, I show user an ASP web-interface to collect user input, keyword etc.,use "<Form name=xxxx Action=MyAction.ASP method=post>........</Form>" then these user input values will be submit to action page to run reports for user.
2
7177
by: james | last post by:
If I have a user control with some control on it like a TextBox's and buttons does calling the default Dispose on my user control cause those inner controls to also be disposed ? Or must I do my own disposing for all those too?? thanks, JIM
9
8550
by: Frank Rizzo | last post by:
I understand the basic premise: when the object is out of scope or has been set to null (given that there are no funky finalizers), executing GC.Collect will clean up your resources. So I have a basic test. I read a bunch of data into a dataset by using a command and a data adapter object, .Dispose(ing) as I go. The moment the data is in the Dataset, the Mem Usage column in the Task Manager goes up by 50 MB (which is about right). I...
11
2012
by: Antonio | last post by:
Hello, here is what I am doing. 1) user accesses web page and clicks button to build report 2) web page accesses web service whose data type is DataSet (public DataSet methodname()...) 3) web service connects to SqlServer, runs BIG report 4) data is returned to web service, web service returns DataSet to web front-end 5) web front-end prompts user to save Excel file which contains the DataSet data
5
4052
by: Mrinal Kamboj | last post by:
Hi , Any pointers when it's absolute necessary to use it . Does it has a blocking effect on the code , as GC per se is undeterministic . what if GC.collect is followed in next line by GC.WaitForPendingFinalizers , will it actually block .
13
1397
by: dm1608 | last post by:
I know all the hype right now from Microsoft is how much easier, faster, and less code ASP.NET 2.0 provides over previous versions. I'm puzzled by this as I could turn out an classic ASP webpage in a few hours to query a database, display a grid/table, and not have much to worry about. Doing the same tasks in ASP.NET 2.0 seems almost trivial, but is it really real-world? I have a classic ASP app that I wrote a few years back that took...
3
18092
by: Mikegtr | last post by:
I need to collect and send data from a rs232 device- it is a simple temperature controller. I need to be able to collect actual temperature ,store the result in database (mysql) and show it in browser in realtime (or with max 10 sec delay). Is there any function/script or smth that could help do that without external software - I don't want to write a small program in e.g. C and then collect it from database. Although it is also an...
4
1971
by: svgeorge | last post by:
I NEED TO COLLECT FROM THE GRIDVIEW(DATASELECTED) IN TO A TABLE(SelectedPayment) -------------------------------------------------------------------------------- How TO COLLECT THE ROWS CHECKED IN CHECK BOX IN THE DATASELECTED TO ANOTHER GRID VIEW ON CLICLING BUTTON I NEED TO COLLECT FROM THE GRIDVIEW(DATASELECTED) IN TO A TABLE(SelectedPayment) SIMILLAR TO HOTMAIL MODEL.....CHECK THE MAILS AND BRING THE CHECKED DATA TO ANOTHER PAGE
0
1089
by: johnspruit | last post by:
I have a method to collect all the controls on a form, also the controls in containers on the form. It seems that some controls, like NumericUpDown also have child controls. I only want controls form 'real' containers. How can i do that? thanks
0
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.