First, we need to understand the principle that no matter how many ascx files are installed in An ASPX page, we still need to generate code for a page, so there is no doubt, I think I have determined that this problem can be solved before solving it. Directly paste the code. The first step is to use the user control to call the parent page:
// Obtain the parent page
Page P = This. Parent. page;
Type pagetype = P. GetType ();
// Method name of the parent page
Methodinfo MI = pagetype. getmethod ("loading ");
// Execute
Mi. Invoke (p, new object [] {"parameter 1", "parameter 2 "});
Call between a user control and a user control:
// Obtain the 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 class method name
Methodinfo MI = pagetype. getmethod ("loading ");
// Parameters
Mi. Invoke (UC, new object [] {"parameter 1", "parameter 2 "});
If you want to get the return value of the method, the return value of the invoke method is the return value of the method execution. The type is object. You can just convert it!