Usercontrol interacting with it's parent page?

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.
 
V

Vaibhav

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
 
N

Naveen K Kohli

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.
 
P

PJ

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

~PJ
 
J

Joe Agster

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top