Get sub control on web user control

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
 
G

Guest

In case anyone else has this problem, I was not making
the components on the user control public, so they could
not be seen.
 
T

Tommy

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top