Get sub control on web user control

  • Thread starter Thread starter Chuck Traywick
  • Start date Start date
C

Chuck Traywick

I have a web user control that contains a textbox.

It is laid out with a grid control.

The grid control is then used on the main web form.

How do you programatically access say
textbox1 which is on webusercontrol1
from inside of webform1?

Thanks

Chuck
 
In case anyone else has this problem, I was not making
the components on the user control public, so they could
not be seen.
 
By default you can't because the textbox in your web user control is
declared as a "Protected" object. A solution would be to create a
public property in the web user control, and return a reference to
your textbox control.

For example,

In your web user control:

Public ReadOnly Property MyTextBox() As Label
Get
Return textBox1
End Get
End Property

In your web form:

Dim myTextBox as TextBox = myUserControl.MyTextBox()

Tommy,
 
Back
Top