Calling Parent Functions

  • Thread starter Thread starter Paul Johnson
  • Start date Start date
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();
 
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
 
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
 
Back
Top