473,747 Members | 2,280 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loop through controls with MaterPage ContentHolder

I changed my aspx page to use a master page. The problem is that I can no
longer loop through the controls on the content page. My question is how do
you loop through the controls on the master page and how do you loop through
the controls on the content page when the content is inside the ContentHolder
control?

Below is an example of the control loop before using a master page.

Sub FindControlsInW ebForm()
Dim strValue As String = ""

'Loop through controls
For Each ctlPage As Control In Page.Controls
If TypeOf ctlPage Is HtmlForm Then
For Each ctlChild As Control In ctlPage.Control s
If TypeOf ctlChild Is Label Then strValue &= "Page.Label .ID = " &
ctlChild.ID & ".ID<br>"

'Panel
If TypeOf ctlChild Is Panel Then
strValue = "Panel.ID = " & ctlChild.ID & ".ID<br>"

For Each ctlGrndChild As Control In ctlChild.Contro ls
If TypeOf ctlGrndChild Is TextBox Then strValue &=
"Panel.TextBox. ID = " & ctlGrndChild.ID & ".ID<br>"
Next ctlGrndChild
End If
Next ctlChild
End If
Next ctlPage
End Sub

--
Thanks in advance,
sck10
Nov 18 '05 #1
4 6371
Hi sck10,

We have reviewed this issue and are currently researching on it. We will
update you ASAP. Thanks for your patience!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 18 '05 #2
Hi sck10:

The hierarchy of controls with MasterPages looks like this:

Page
- MasterPage
- HtmlForm
- ContentPlaceHol der
- The TextBoxes, etc.

So your logic could look something like the following.

For Each ctlMaster As Control In Page.Controls
If TypeOf ctlMaster Is MasterPage Then
For Each ctlForm As Control In ctlMaster.Contr ols
If TypeOf ctlForm Is HtmlForm Then
For Each ctlContent As Control In ctlForm.Control s
If TypeOf ctlContent Is ContentPlaceHol der Then
For Each ctlChild As Control In ctlContent.Cont rols
' Do work...
Next
End If
Next
End If
Next
End If
Next

--
Scott
http://www.OdeToCode.com

On Fri, 24 Sep 2004 09:02:19 -0700, "sck10" <sc***@online.n ospam>
wrote:
I changed my aspx page to use a master page. The problem is that I can no
longer loop through the controls on the content page. My question is how do
you loop through the controls on the master page and how do you loop through
the controls on the content page when the content is inside the ContentHolder
control?

Below is an example of the control loop before using a master page.

Sub FindControlsInW ebForm()
Dim strValue As String = ""

'Loop through controls
For Each ctlPage As Control In Page.Controls
If TypeOf ctlPage Is HtmlForm Then
For Each ctlChild As Control In ctlPage.Control s
If TypeOf ctlChild Is Label Then strValue &= "Page.Label .ID = " &
ctlChild.ID & ".ID<br>"

'Panel
If TypeOf ctlChild Is Panel Then
strValue = "Panel.ID = " & ctlChild.ID & ".ID<br>"

For Each ctlGrndChild As Control In ctlChild.Contro ls
If TypeOf ctlGrndChild Is TextBox Then strValue &=
"Panel.TextBox .ID = " & ctlGrndChild.ID & ".ID<br>"
Next ctlGrndChild
End If
Next ctlChild
End If
Next ctlPage
End Sub


Nov 18 '05 #3
Thanks for Scott's informative suggestions.

Hi sck10,

Scott has provide the detailed description on the MasterPage customized
page's control hierarchy and here is another blog article which has also
mentioned this hehavior:

http://dotnetjunkies.com/WebLog/jpal.../01/23919.aspx

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4
Hi Sck10,

Have you had a chance to check the former messages or have you got any
further ideas on this problem. If there are any thing else we can help,
please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #5

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

Similar topics

4
3468
by: Ryan Liu | last post by:
How to loop though controls on the form? I set each control's TabStop and TabIndex, but at run time, I press Tab key, it jump though first control to last control and does not go back to the first one unless I use Alt + Tab to go reverse direction. How can I write C# code to allow user just to use Tab kek to loop though the controls? Thanks!
4
1808
by: David A. Beck | last post by:
Is there a way I can loop through a form object in ASP.NET codebehind like in VB.NET and get all of the controls?
4
3708
by: Ryan Ternier | last post by:
Thanks for the previous help guys! I got my list box issue working, but now i'm trying to loop through all the items in my page. I want to find each listbox, once I do i strip the ID down to find what I need so I can populate a DB. lstTest is dim'd as a ListBox, and I thought I could just do:
0
418
by: Steven K | last post by:
Hello, I just worked through finding controls on a page with and without a panel. My question is how do you loop through controls if you are using a master page and your content is inside the ContentHolder control? Thanks in advance, Steven Sub FindControlsInWebForm()
33
3658
by: Brian | last post by:
I have a list of plain HTML radio buttons that I want to be able to loop through, get the values from them and insert them into a db. each one should be a separate record... Can anyone please give me some kind of example on how to do this???? I am doing this in asp.net VB. Please let me know if you need any additional information. Thanks
3
1324
by: Kezza | last post by:
Hi There.. I have dynamically created some textbox and checkbox controls by adding them to a panel. Now I would like to get the values out. I have created a for each loop that I can see the controls Unique ID with. But I for the life of me can't figure out how to see the value the control is storing. Could somebody please help me. I'm thinking that I might need to use something like "findcontrol", but this wouldn't make sense to me. ...
8
2527
by: dominique | last post by:
Hi, Is it possible (in vb.net with WinForms) to loop throw controls inside a container (form or panel) sorting the controls on a property (.tabindex for example) ? My problem : on several forms (or panels), i have many controls (inherited controls from base controls : MyTextbox, MyCombobox ..). I add a new property on these controls : .BeginningGroup (boolean : yes or no).
4
1646
by: Bart | last post by:
Hi, I have a menu on my master page. When I click on a menu item the state is reset after the page is redirected to the NavigateURL. How can fix this? Thanks Bart
10
1866
by: Derek Hart | last post by:
I am going in circles trying to loop through properties on 3rd party controls. For example, I have a textbox that has its maximum length located at MyTextBox.Properties.MaxLength - instead of the dotnet textbox which is MyTextBox.MaxLength. If I loop a built in dotnet control, it finds the property no problem. But looping through the 3rd party control, Properties.MaxLength does not get listed. I was hoping to find how it names it using...
0
8979
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8818
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
9355
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
9307
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
6790
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
6069
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
4589
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...
1
3296
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
3
2203
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.