Usercontrol interacting with it's parent page?

Discussion in 'ASP .Net' started by John, Jul 1, 2003.

  1. John

    John Guest

    Hi all,

    Is it possible for a usercontrol to call a public method of a page it is
    contained within? If so, how?

    Regards
    John.
    John, Jul 1, 2003
    #1
    1. Advertising

  2. John

    Vaibhav Guest

    Hi

    Since your page is a class too. In your user control you can create an
    instance of it and then call its method.

    But i also doubt on this being the best way and only way to do what u want
    to do.

    HTH


    "John" <> wrote in message
    news:...
    > Hi all,
    >
    > Is it possible for a usercontrol to call a public method of a page it is
    > contained within? If so, how?
    >
    > Regards
    > John.
    >
    >
    Vaibhav, Jul 1, 2003
    #2
    1. Advertising

  3. Every Control has a property named "Page". This gives you the refrence to
    the containing page object. YOu can call public methods through this
    refrence.

    --
    Naveen K Kohli
    http://www.netomatix.com
    "John" <> wrote in message
    news:...
    > Hi all,
    >
    > Is it possible for a usercontrol to call a public method of a page it is
    > contained within? If so, how?
    >
    > Regards
    > John.
    >
    >
    Naveen K Kohli, Jul 1, 2003
    #3
  4. John

    PJ Guest

    Mark the method public static and pass any necessary state information as
    arguments.

    ~PJ

    "John" <> wrote in message
    news:...
    > Hi all,
    >
    > Is it possible for a usercontrol to call a public method of a page it is
    > contained within? If so, how?
    >
    > Regards
    > John.
    >
    >
    PJ, Jul 2, 2003
    #4
  5. John

    Joe Agster Guest

    Yes, but you need to redefine the Page property from
    within the user control to be of the type containing the
    public method you want to access:

    public class MyUC
    inherits UserControl

    protected readonly shadows property Page as MyPage
    get
    return ctype(mybase.Page, MyPage)
    end get
    end property

    '... rest of class

    'call method in containing page
    Page.Method()

    end class



    >-----Original Message-----
    >Hi all,
    >
    >Is it possible for a usercontrol to call a public method

    of a page it is
    >contained within? If so, how?
    >
    >Regards
    >John.
    >
    >
    >.
    >
    Joe Agster, Jul 2, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oleg Ogurok

    Parent page name (Usercontrol)

    Oleg Ogurok, Jun 18, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    1,261
  2. John A Grandy
    Replies:
    1
    Views:
    3,245
    Karl Seguin
    Jul 25, 2005
  3. Jimi
    Replies:
    1
    Views:
    7,608
  4. Liming
    Replies:
    1
    Views:
    407
    Liming
    Apr 25, 2006
  5. DavidS
    Replies:
    4
    Views:
    412
    DavidS
    Mar 28, 2008
Loading...

Share This Page