473,394 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

getting child controls of a user control

I'm trying to create a custom 'summary validator'.

I want to walk through the validation controls on my ASCX page and then grab
the ones that are invalid.

So, I started with this to do the walkthrough:

for each cntrl as Control in Page.Controls
response.write (cntrl.GetType.ToString & "<br />")
next

The problem is that this only returns the controls on the parent .aspx
page...not the controls on the .ascx usercontrol page (the page with this
code). Is this simply a matter of different syntax or do I need to tackle
this a different way?

-Darrel
Nov 18 '05 #1
3 1986
need to do this recursively:

sub Page_Load
WriteControls(Page)
end sub

private sub WriteControls(parent As Control)
for each child as Control in parent.Controls
if child.HasControls then
WriteControls(child0
end if
Response.Write(child.GetType.ToString() & "<br />")
end sub

karl

"darrel" <no*****@hotmail.com> wrote in message
news:uL**************@TK2MSFTNGP14.phx.gbl...
I'm trying to create a custom 'summary validator'.

I want to walk through the validation controls on my ASCX page and then grab the ones that are invalid.

So, I started with this to do the walkthrough:

for each cntrl as Control in Page.Controls
response.write (cntrl.GetType.ToString & "<br />")
next

The problem is that this only returns the controls on the parent .aspx
page...not the controls on the .ascx usercontrol page (the page with this
code). Is this simply a matter of different syntax or do I need to tackle
this a different way?

-Darrel

Nov 18 '05 #2
> need to do this recursively:

Oh..DUH! Of course. That works great!

Ok, second question ;o)

I don't need to go through every control. Just this particular one
(contactForm.ascx). Is there a way only read through that specific control's
controls?

It seems that I should be able to call a specific control via index:

parent.controls(1)

but that doesn't seem to work, so I'm guessing I'm off on my syntax.

-Darrel
Nov 18 '05 #3
How is contactForm.ascx added?

programmatically?
dim c as control = Page.LoadControl("contactForm.ascx")
x.Controls.Add(c)

if so, you can just do:
WriteControls(c) where "c" is the control loaded above
or declaratively?
<uc:contactForm id="form" runat="server" />

if so, you should declare contactForm in your codebehind
protected contactForm as ContactForm 'assuming that's the typ

then in page_load or wherever
WriteControl(contactForm)

Karl
"darrel" <no*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
need to do this recursively:
Oh..DUH! Of course. That works great!

Ok, second question ;o)

I don't need to go through every control. Just this particular one
(contactForm.ascx). Is there a way only read through that specific

control's controls?

It seems that I should be able to call a specific control via index:

parent.controls(1)

but that doesn't seem to work, so I'm guessing I'm off on my syntax.

-Darrel

Nov 18 '05 #4

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

Similar topics

1
by: msnews.microsoft.com | last post by:
I'm adding multiple web controls to the placeholder controls collection, but even when doing the for each and recursion method of getting the web controls, I'm only getting the first web control...
1
by: Aquila Deus | last post by:
Hi all! Following is the method I use to insert child controls into user controls, so that you may use them just like ordinary custom controls: ...
0
by: Scott McChesney | last post by:
I have a problem I hope you folks can help me with. I have an application that is using a tab-based interface, with the ability for users to drag an item from a ListBox onto the tab control. ...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: ssoffline | last post by:
hi i have an app in which i can drop objects onto a form and move them, it consists of graphics (lines), i am using double buffering to avoid filckering in the parent control which is a panel,but...
5
by: Earl | last post by:
I need to call a method on an owned child form, and am wondering if the best way of doing this is to capture the Closing event of the form that passes control back to the form where I have the...
1
by: Seth Petry-Johnson | last post by:
Is there a way to compile a user control into a redistributable assembly , but still have access to its child controls using the .Controls property? Here's what I mean: I have a user control...
1
by: sean | last post by:
I'm trying to create "rubber-band" rectangles by overriding the OnPaint method to place rectangles on top of all graphic controls, but when I call Me.Invalidate() (when the user moves the mouse),...
2
by: Bob Johnson | last post by:
..NET 3.5: I have placed two controls at the top of an Mdi parent form. The top-most control is a Panel that is docked to the Top. Immediately below the Panel is a user control that is Anchored to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.