User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Jun 2008
Posts: 1
Reputation: AsifAshraf is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
AsifAshraf AsifAshraf is offline Offline
Newbie Poster

Where is SearchControl("xxx")?

  #1  
Jun 24th, 2008
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
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2008
Posts: 48
Reputation: a496761 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
a496761 a496761 is offline Offline
Light Poster

Re: Where is SearchControl("xxx")?

  #2  
Jun 25th, 2008
I'm primarily a vb.net developer, but this line looks strange to me:
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 7:39 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC