473,406 Members | 2,894 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,406 software developers and data experts.

WebControls and sub controls... problem with FindControl... Why?

Hi,
I have a custom WebControl. I fire an event and send, as the EventArg,
another WebControl that contains sub controls (ParseChildren(true))... It
can contain anything, but I want to find one control... Let's say the
control I want to find is "myControl". So I call
e.theObject.FindControl("myControl"); It always returns null and I know the
name of the control is good (that's the ID I gave it, is it possible it has
changed because it's the child of a WebControl?). When I look at "theObject"
in the Watch window, I got to it's base (WebControl), the to the "Controls"
property, then to the non-public fields to find the collection of controls
it contains and I find my object with the name I want...

The question is... Is there a way for the FindControl function not to find a
control contained in the Controls collection? It's there for sure, why
FindControl does not find it?

thanks

ThunderMusic
Oct 9 '06 #1
2 3467
somewhere on the net, I found this little method and guess what, my control
shows, but FindControl does not find it... Should I create my own
FindControl method?

here's the method I found :
private string IterateThroughChildren(Control parent)
{
StringBuilder sb = new StringBuilder();
foreach (Control c in parent.Controls)
{
if (c.UniqueID != null)
{
sb.Append("<li>" + c.UniqueID.ToString() + "</li>");
if (c.Controls.Count 0)
{
sb.Append("<ul>");
sb.Append(IterateThroughChildren(c));
sb.Append("</ul>");
}
}
}
return sb.ToString();
}

thanks

ThunderMusic

"ThunderMusic" <NO.danlat.at.hotmail.com.SPAMa écrit dans le message de
news: %2****************@TK2MSFTNGP02.phx.gbl...
Hi,
I have a custom WebControl. I fire an event and send, as the EventArg,
another WebControl that contains sub controls (ParseChildren(true))... It
can contain anything, but I want to find one control... Let's say the
control I want to find is "myControl". So I call
e.theObject.FindControl("myControl"); It always returns null and I know
the name of the control is good (that's the ID I gave it, is it possible
it has changed because it's the child of a WebControl?). When I look at
"theObject" in the Watch window, I got to it's base (WebControl), the to
the "Controls" property, then to the non-public fields to find the
collection of controls it contains and I find my object with the name I
want...

The question is... Is there a way for the FindControl function not to find
a control contained in the Controls collection? It's there for sure, why
FindControl does not find it?

thanks

ThunderMusic

Oct 9 '06 #2
finally I did my own FindControl method, but I want to know if there is a
better solution (or even a cause) to this...

thanks

ThunderMusic

"ThunderMusic" <NO.danlat.at.hotmail.com.SPAMa écrit dans le message de
news: %2****************@TK2MSFTNGP02.phx.gbl...
Hi,
I have a custom WebControl. I fire an event and send, as the EventArg,
another WebControl that contains sub controls (ParseChildren(true))... It
can contain anything, but I want to find one control... Let's say the
control I want to find is "myControl". So I call
e.theObject.FindControl("myControl"); It always returns null and I know
the name of the control is good (that's the ID I gave it, is it possible
it has changed because it's the child of a WebControl?). When I look at
"theObject" in the Watch window, I got to it's base (WebControl), the to
the "Controls" property, then to the non-public fields to find the
collection of controls it contains and I find my object with the name I
want...

The question is... Is there a way for the FindControl function not to find
a control contained in the Controls collection? It's there for sure, why
FindControl does not find it?

thanks

ThunderMusic

Oct 9 '06 #3

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

Similar topics

5
by: Sue | last post by:
On code-behind page: (attributes set programatically for each of these elements) linkbutton added to tablecell textbox added to tablecell tablecells added to tablerow tablerow added to table...
9
by: wASP | last post by:
Hello again to all of you geniuses, I'm having a problem trying to load dynamic controls at the initialization phase. I've read the docs, and I thought I had it figured out:...
3
by: Andreas Klemt | last post by:
Hello, I have this: <table id="myTable" runat="server"> <tr> <td><asp:label id="lblText" runat="server"></asp:label> <asp:button id="btn1" runat="server"></asp:button> <asp:button id="btn2"...
2
by: Shawn | last post by:
Hi. I'm trying to loop through all webcontrols in my System.Web.UI.HtmlControls.HtmlForm. This is my code: Dim form As HtmlForm Dim control As Control form = Me.FindControl("completion")...
5
by: Amelyan | last post by:
How can I get state of dynamically created controls (RadioButton, CheckBox, TextBox.Text) on post back when I click submit button? The only way I know is by traversing Response.Form enumberator;...
6
by: Steve | last post by:
I'm trying to iterate over all the form controls in my MasterPages content page. Basically, I've got dropdowns, textboxes, etc that I want to format in Page_Load() I've added this code to my...
4
by: tshad | last post by:
Is there a way for a User Control to access an object (such as label or textbox) on the .aspx page that calls it? For example: x.aspx ************************************** .... Sub...
3
by: Andreas Wöckl | last post by:
Hi Group! I have a web form that is created dynamically - so I create Textboxes, RadioButtonLists, CheckBoxLists and so on - I have found some articles that there may be some problems with...
2
by: Andy B | last post by:
I have the following listView control on a page: <asp:ListView ID="ListView1" runat="server" ItemPlaceholderID="PlaceHolder1"> <ItemTemplate> <dl> <dt>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.