Iterate TextBoxes
Iterate TextBoxes
Iterate TextBoxes
Iterate TextBoxes
Iterate TextBoxes
Iterate TextBoxes Iterate TextBoxes Iterate TextBoxes Iterate TextBoxes Iterate TextBoxes Iterate TextBoxes Iterate TextBoxes Iterate TextBoxes
Iterate TextBoxes Iterate TextBoxes
Iterate TextBoxes
Go Back  Xtreme Visual Basic Talk > > > Iterate TextBoxes


Reply
 
Thread Tools Display Modes
  #1  
Old 08-08-2008, 08:17 AM
Jamesanthony's Avatar
Jamesanthony Jamesanthony is offline
Contributor
 
Join Date: May 2003
Location: Dublin
Posts: 502
Default Iterate TextBoxes


Hi All
This works with VB.NET
Is there a controls collection in ASP
I am using a master page
I am trying to iterate thourgh textboxs on Child page

For Each cTrl In Me.Controls
If TypeOf cTrl Is TextBox Then
Do something
End If
Next

Thanks in Advance
Reply With Quote
  #2  
Old 08-08-2008, 09:41 AM
wayneph's Avatar
waynephIterate TextBoxes wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

If it is in a child page you need to take the place holder into account.

Code:
For Each ctrl As Control In Me.ContentPlaceHolder1.Controls
Also remember that the text literals between your controls will show up in the Controls collection.
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
  #3  
Old 08-08-2008, 09:54 AM
Jamesanthony's Avatar
Jamesanthony Jamesanthony is offline
Contributor
 
Join Date: May 2003
Location: Dublin
Posts: 502
Default

Hi Wayneph
Thanks for the reply BUT

Get this message

Error 1 'ContentPlaceHolder1' is not a member of 'Maintain'

Where maintain is my child form
Default.Master is the masterpage
Content1 is the Contentplaceholder1 name
Tried content1.Controls
Am I doing something Wrong
Thanks
Reply With Quote
  #4  
Old 08-08-2008, 11:22 AM
wayneph's Avatar
waynephIterate TextBoxes wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

Is this code running on the master page or the content page?

My code is based on the assumption that you are running on the master page trying to get the controls in the child.
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
  #5  
Old 08-08-2008, 02:34 PM
Jamesanthony's Avatar
Jamesanthony Jamesanthony is offline
Contributor
 
Join Date: May 2003
Location: Dublin
Posts: 502
Default

On the Child page I have the textboxes that I am trying to access
Not sure what you mean
I dont want to do anything with the master page, except that the child page is embedded in master page
Thanks again for replying
Reply With Quote
  #6  
Old 08-08-2008, 04:44 PM
wayneph's Avatar
waynephIterate TextBoxes wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

Well, I thought there would be a fairly easy way of getting to this directly on the page, and I assume that if I dig around the Controls collection a little more, I could come up with it. (They're all in there, you just need to figure out how deep you need to start.) As it stands, I think this will get what you're looking for.

Try this... (Obviously replace ContentPlaceHolder1 with the name of the placeholder on your MasterPage.)
Code:
For Each ctrl As Control In Me.Master.FindControl("ContentPlaceholder1").Controls
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
  #7  
Old 08-08-2008, 05:07 PM
Jamesanthony's Avatar
Jamesanthony Jamesanthony is offline
Contributor
 
Join Date: May 2003
Location: Dublin
Posts: 502
Default

Great stuff
Tried that and no errors
Havent ou worked out what to do next but at least The hard part is done
I have a question though
How did you work that out
I have tried MSDN and I cant understand it
Do you think Its written well
I loved VB6
You key in help combobox and you get an example with all events etc.
MSDN is so complicated or am I not giving it enough time
I hated VB.net at first, now I kinda like it, But LOVE VB6
Suppose its that old demon CHANGE, will have to study etc
Well any comments appreciated
and
Really BIG THANKS for the help
Reply With Quote
  #8  
Old 08-10-2008, 06:01 AM
wayneph's Avatar
waynephIterate TextBoxes wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

Basically I started the application up in debug mode and put a breakpoint on the first line. Then I used the "Quick Watch" tool in Visual Studio to explore through the different properties that were available on the page until I found what I was looking for.

Like I said, I had hoped that I could do it without requiring going up to the "Master" property, but that was the easiest way to isolate the Content Place Holder.
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Iterate TextBoxes
Iterate TextBoxes
Iterate TextBoxes Iterate TextBoxes
Iterate TextBoxes
Iterate TextBoxes
Iterate TextBoxes Iterate TextBoxes Iterate TextBoxes Iterate TextBoxes Iterate TextBoxes Iterate TextBoxes Iterate TextBoxes
Iterate TextBoxes
Iterate TextBoxes
 
Iterate TextBoxes
Iterate TextBoxes
 
-->