Calling Parent Functions

P

Paul Johnson

I want a custom control to be able to call a function that is in it parent,
is this posible?

I have tried things like this.Parent.FunctionName();
 
C

Captain Chaos

Yes, "Parent" should be the right way.

Maybe your Problem is that Parent returns you the Type
Windows.Forms.Control.

Simple write it this way:

dim c as Project1.MyOwnControl 'The Type of your UserControl
c = me.Parent 'Cast it to your UserControltype
c.FunctionName(); 'Call the fun
 
P

Paul Johnson

I still dont understand this.

I have a aspx page called EditProperty.aspx which has a custom control
PropertyDetails.ascx.

Say in EditProperty.aspx I have a simple function like this.
void SayHi() {
Response.Write( "hi" );
}

I want to be able to call that function from within the code in
PropertyDetails.ascx. I have tried things like
void Page_Load() {
ASP.EditProperty_aspx objTheParent = (ASP.EditProperty_aspx)this.Parent;
objTheParent.SayHi();
}

But I think ASP.EditProperty_aspx can only be used in the EditProperty.aspx
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,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top