•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 397,836 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,571 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 355 | Replies: 1
![]() |
•
•
Join Date: Jun 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
hi
I'm creating a UserControl, I want to set a property like TargetDropDownID which is supposed to be a "string" type of data. Not a DropDownList Control so that i can set this property in html view.
OK the Find Control doesn't help in this regard because the whoever will use my UserControl will not be able to tell what is the container of that DropDownList as FindControl seems to have the Container ... like Page.FindControl will search only ONE level search on "Page" object.
Now is there anyway that i can loop through ALL the Page and its Children until i find a specific DropDownList Control by its Id in string.
Ok i found this method in asp.net forums like
But Frankly it thrown an error on very first usage
Multiple controls with the same ID 'Image1' were found. FindControl requires that controls have unique IDs.
Can anybody help me?
I'm wondering how AJAX controls work we just set TargetControlID in some extenders and the Extenders Find their control everytime ... HOW ? is this only specific for Microsoft Team?
I'm creating a UserControl, I want to set a property like TargetDropDownID which is supposed to be a "string" type of data. Not a DropDownList Control so that i can set this property in html view.
OK the Find Control doesn't help in this regard because the whoever will use my UserControl will not be able to tell what is the container of that DropDownList as FindControl seems to have the Container ... like Page.FindControl will search only ONE level search on "Page" object.
Now is there anyway that i can loop through ALL the Page and its Children until i find a specific DropDownList Control by its Id in string.
Ok i found this method in asp.net forums like
1 private Control FindControlRecursive(Control root, string id)
2 {
3 if (root.ID == id)
4 {
5 return root;
6 }
7
8 foreach (Control c in root.Controls)
9 {
10 Control t = FindControlRecursive(c, id);
11 if (t != null)
12 {
13 return t;
14 }
15 }
16
17 return null;
18 }
But Frankly it thrown an error on very first usage
Multiple controls with the same ID 'Image1' were found. FindControl requires that controls have unique IDs.
Can anybody help me?
I'm wondering how AJAX controls work we just set TargetControlID in some extenders and the Extenders Find their control everytime ... HOW ? is this only specific for Microsoft Team?
Last edited by AsifAshraf : Jun 24th, 2008 at 2:15 am.
•
•
Join Date: Feb 2008
Posts: 48
Reputation:
Rep Power: 1
Solved Threads: 3
I'm primarily a vb.net developer, but this line looks strange to me:
I'd think you'd need to change the word Control to function. What error are you getting? How are you calling the function?
private Control FindControlRecursive(Control root, string id)
I'd think you'd need to change the word Control to function. What error are you getting? How are you calling the function?
Last edited by a496761 : Jun 25th, 2008 at 11:57 am.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
Other Threads in the ASP.NET Forum
- Previous Thread: need help,,asp.net and sql update problem
- Next Thread: Help: Website Login and Protect Content


Linear Mode