Find Controls Recursively
Category:C#, VB.NET, ASP.NET
Version Compatibility: Visual Basic.NET
This code snippet was useful when I needed to access a control inside another control. This function finds the first control with the name you pass in for a page or control. If you give it 'Page' as the first argument, it will give you the first control used on the page. To find a control on a Page with ID="WantToFindThis", Dim ThisControl As Control = RecursiveFindControl(Page, "WantToFindThis"). And if you wanted to change the text of that control, ThisControl.Text = "Something new". Warning: This may not find the control you are after if you have several controls on the page with that name.
Instructions: Copy the declarations and code below and paste directly into your VB project.