How to access: a page from a User control, and another User control from another one?

How to access: a page from a User control, and another User control from another one?

Post by qwert » Fri, 01 Oct 2004 18:55:06


I have two User controls in a page.
Them ID-propertys are example UC1 and UC2.

In code behind file they are declared:
Public UC1 As UC1
Public UC1 As UC1

From the page I can call them with their name (UC1 and UC2) and access
their public propertys and functions.

How can I access the page from a user control?
How can I access another user control from another one?
 
 
 

How to access: a page from a User control, and another User control from another one?

Post by Karl Segui » Fri, 01 Oct 2004 21:27:09

Each user control has a Page property, which gives it access to the page.
In order to access those properties, you need to have it strongly-typed to
the class of your page (for example, let's say WebForm1):

dim otherControl as UC1 = ctype(Page, WebForm1).UC1

Karl

--
MY ASP.Net tutorials
http://www.yqcomputer.com/

 
 
 

How to access: a page from a User control, and another User control from another one?

Post by Shiv » Fri, 01 Oct 2004 21:39:40

Hi,

UserControl.Page property gives you the reference to the containing page.

One way to access an user control from another (both on the same page) is to
use the page-usercontrol hierarchy itself. If for example PAGE1 contains UC1
and UC2 (both are public), from UC1, DirectCast(Me.Page, PAGE1).UC2 gives
you access to UC2.

HTH.



I have two User controls in a page.
Them ID-propertys are example UC1 and UC2.

In code behind file they are declared:
Public UC1 As UC1
Public UC1 As UC1

From the page I can call them with their name (UC1 and UC2) and access
their public propertys and functions.

How can I access the page from a user control?
How can I access another user control from another one?