Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to access: a page from a User control, and another User controlfrom another one?

Reply
Thread Tools

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

 
 
qwerty
Guest
Posts: n/a
 
      09-30-2004
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?
 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      09-30-2004
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.openmymind.net/


"qwerty" <(E-Mail Removed)> wrote in message
news:415bd7fd$0$3665$(E-Mail Removed)...
> 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?



 
Reply With Quote
 
 
 
 
Shiva
Guest
Posts: n/a
 
      09-30-2004
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.

"qwerty" <(E-Mail Removed)> wrote in message
news:415bd7fd$0$3665$(E-Mail Removed)...
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?


 
Reply With Quote
 
Scott Allen
Guest
Posts: n/a
 
      09-30-2004
A user control has a Page property you can use to get to the Page
containing the control.

WebForm1 form1 = (WebForm1)this.Page;

If the page then exposes the user controls as public properties or as
public fields (as you have done, it appears), you can reach them
through the page reference:

UC2 uc2 = form1.UC2

or

UC2 uc2 = ((WebForm1)this.Page).UC2;

HTH,

--
Scott
http://www.OdeToCode.com/

On Thu, 30 Sep 2004 12:55:06 +0300, qwerty <(E-Mail Removed)> wrote:

>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?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
accessing the web user control's control from a web page and set a value from another web page Reny J Joseph Thuthikattu ASP .Net 1 12-30-2004 12:21 PM
How can I cache a user control in a page and uncache it in another page? Quentin Huo ASP .Net 1 08-06-2004 05:33 PM
how ASP.NET page gets user input from another ASP.NET page?? Matthew Louden ASP .Net Web Controls 5 11-24-2003 06:59 AM
how ASP.NET page gets user input from another ASP.NET page?? Matthew Louden ASP .Net 4 11-24-2003 06:59 AM
Passing value from one script on one page to another script on another page. Robert Cohen ASP General 3 07-15-2003 01:46 PM



Advertisments