Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: UserControls and Page Events


Message #1 by "Bob Riley" <briley@c...> on Fri, 28 Feb 2003 05:30:48
Thanks for your help!

-----Original Message-----
From: Howard Cheng [mailto:howcheng@i...]
Sent: Friday, February 28, 2003 12:46 PM
To: ASPX_Professional
Subject: [aspx_professional] Re: UserControls and Page Events


Although I haven't tried this, theoretically it should be possible. The
UserControl type has a Page property which references the page it 
contains,
so you could probably do something like:

public class MyPage : System.Web.UI.Page
{
     public void MyFunction()
     {
     }
}

public class MyControl : System.Web.UI.UserControl
{
     protected void MyHandler(object sender, EventArgs e)
     {
         MyPage page =3D this.Page;
         page.MyFunction();
     }
}

Give it a shot.

At 05:30 AM 2/28/2003 +0000, Bob Riley wrote:
>When a button is pressed in a usercontrol - is it also possible to have 
a
>sub routine that handles some code for this event in the main page as
>well?
>I have a UserControl that displays a checklist in a datalist.  A button
>on the usercontrol records the checked items in a datalist and stores
>them in an arraylist.  Depending on which page the usercontrol resides
>in - different code needs to be executed.  Is it possible - when the
>button is pressed in the usercontrol - to have an event fired in both 
in
>the usercontrol, and on the parent page?

::::::::::::::::::::::::::::::::::
Howard Cheng
http://www.howcheng.com/
howcheng at ix dot netcom dot com
AIM: bennyphoebe
ICQ: 47319315



  Return to Index