A A A
C  C  Off 

Finding a control on a page

Quite often, you will need to be able to get at a field value on a page but you may be in a different class, and naturally you will not be able to "see" the control that you require, as the control is registered in a different section.

 

By using Page.FindControlRecursively, the ability to get at these controls is handled very nicely.

 

So, for example, if there was a text box on a page with an ID of ClientTextBox, and you happen to be in a different section, not being able to get there directly, you can do the following:

 

(VB.NET) Dim clientTextBox as TextBox = CType(Me.Page.FindControlRecursively("ClientTextBox"),TextBox)

OR

(C#) TextBox clientTextBox = (TextBox))Me.Page.FindControlRecursively("ClientTextBox");

 

Ricci

  • Facebook
  • Twitter
  • Digg It!
Leave a comment
Close

Enter your details and click subscribe to sign up to our newsletter

 *
   
 
 

* Required Field

Subscribe