473,791 Members | 3,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Fin dControl("myCon trol"); 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 3480
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 IterateThroughC hildren(Control parent)
{
StringBuilder sb = new StringBuilder() ;
foreach (Control c in parent.Controls )
{
if (c.UniqueID != null)
{
sb.Append("<li> " + c.UniqueID.ToSt ring() + "</li>");
if (c.Controls.Cou nt 0)
{
sb.Append("<ul> ");
sb.Append(Itera teThroughChildr en(c));
sb.Append("</ul>");
}
}
}
return sb.ToString();
}

thanks

ThunderMusic

"ThunderMus ic" <NO.danlat.at.h otmail.com.SPAM a écrit dans le message de
news: %2************* ***@TK2MSFTNGP0 2.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.Fin dControl("myCon trol"); 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

"ThunderMus ic" <NO.danlat.at.h otmail.com.SPAM a écrit dans le message de
news: %2************* ***@TK2MSFTNGP0 2.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.Fin dControl("myCon trol"); 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
5292
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 (table.ID is TestTable) On .aspx page: <HeaderTemplate> <asp:Table ID="TestTable" runat="Server" /> </HeaderTemplate>
9
17631
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: <>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<> <>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<> .NET Framework Class Library Control.Init Event
3
4308
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" runat="server"></asp:button> <asp:button id="btn3" runat="server"></asp:button> </td>
2
4230
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") For Each control In form.Controls ....
5
3519
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; Response.Form.GetEnumerator(), etc. while, identifying specific controls by programmatically assigned unique id (e.g. MyButton_AnswerID_123). However, I am not sure if that is the proper way. What is the common practice?
6
3270
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 Page_Load() event <code> private void ConfigureFormControls() { Color borderColor = ColorTranslator.FromHtml("#F5F5F5"); Color fontColor = borderColor;
4
1685
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 Page_Load(s as Object, e as EventArgs) LoadControl("x.ascx")
3
3103
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 postback - but if I press a submit button the textboxes keep the value. My problem is the following: I would like to use this Code to collect the data: 'Collects values - is calles from a button
2
2363
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
10428
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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
10156
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,...
0
9997
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9030
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
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
5435
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
4110
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
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.