Solution to the FindControl problem


Posted on 16th Feb 2014 07:03 pm by admin

I have seen may posts about having problems with the FindControl method. Most seem to come about because the control being searched for is nested within a container other than the webform.I came across this code (sorry dont remember the web site) that I have posted in response to many of the posts related to this type of problem. I thought it would be easier if I post this code here for others to find./// /// Finds a Control recursively. Note finds the first match that exists /// /// Should be the lowest container in the heirarchy, for eg dont choose Master page if you can pick the specific panel /// ID of the control you are looking for /// the control if found else null private static Control FindControlRecursive(Control Root, string Id) {if (Root.ID == Id) return Root; foreach (Control Ctl in Root.Controls) {Control FoundCtl = FindControlRecursive(Ctl, Id); if (FoundCtl != null) return FoundCtl; }return null; }
No comments posted yet

Your Answer:

Login to answer
148 Like 21 Dislike
Previous forums Next forums
Other forums

problems with contact forms that are only protected against SQL injections
What could be a potential problem with contact forms that are only protected against SQL injections

simple ping code
been searchin the site/web and found code thats simple but doesnt work.

I have a personal we

Implementing Single Sign-On using SAML 1.1, x.509, LDAP in C#.net
Hi, I got a requirement from the client i.e implementing single sing on using SAML 1.1( LDAP &

Generate PDF
Hi guys,

I would like to know if there is a way to generate pdf when clicking on a link. In f

Bar charts using Graphical Framework.
I am using Graphical Frameworks(GFW) to create a chart Graphic . There is no problem with the data d

Text file to .Dat file Conversion in PHP
Hi All,
Could anybody provide code for Text file to .Dat file Conversion in PHP.

Tha

Calling strings from other php class
I have test1.php{
$string1;
$string2;
....
... //10 strings in this class <

undefined offset help
Hi All,

I kept getting undefined offset PHP notice for a simple for loop. For eg
$va = arr

Simpler method of getting variables from mysql
Hi Guys,

I'm trying to streamline my CMS's code and as I was writing a new page it occured to

Find current logon time
Hi,
in my sql script i want to query and find out the logon time of the current session.
<

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash