Usercontrol interacting with it's parent page?

  • Thread starter Thread starter John
  • Start date Start date
J

John

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.
 
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
 
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.
 
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
 
Back
Top