The User Control calls the parent page:
// Get parent page
Page P = This . Parent. page;
Type pagetype = P. GetType ();
// Method Name of the parent page
Methodinfo Mi = Pagetype. getmethod ( " Loading " );
// Run
Mi. Invoke (p, New Object [] { " Parameter 1 " , " Parameter 2 " });
Call between a user control and a user control: // Get parent page
Page P = This . Parent. page;
// Obtain the child control of the parent page
Usercontrol UC = P. findcontrol ( " Tj_receiptlist2 " ) As Usercontrol;
Type pagetype = UC. GetType ();
// Parent method name
Methodinfo Mi = Pagetype. getmethod ( " Loading " );
// Parameters
Mi. Invoke (UC, New Object [] { " Parameter 1 " , " Parameter 2 " });
Set Properties between a user control and a user control:
// Get parent page
Page P = This . Parent. page;
// Obtain the child control of the parent page
Usercontrol UC = P. findcontrol ( " Aabb1 " ) As Usercontrol;
Type pagetype = UC. GetType ();
// Parent method name
Propertyinfo Mi = Pagetype. getproperty ( " Attribute name " );
/// mi. invoke (UC, new object [] {});
mi. setvalue (UC, attribute value, null );
supplement:
1. if you want to obtain the return value of the method, the invoke method returns the return value of the method execution, whose type is object, you just need to switch it!
2. A value is also written in the title, but not in the Code ? Oh, can we get the value in a way that we can? In addition, there are many ways, so I won't talk about it here :)
note:
the method for calling the parent page or other user controls must be public!