.NET同一页面 用户控件调用父页面方法与控件之间的方法调用

it2022-05-05  115

1、用户控件调用父页面方法

    //获得父页面

    Page p =this.Parent.Page;

    Type pageType = p.GetType();

    //父页面的方法名

    MethodInfo mi = pageType.GetMethod("SaveBill");

    //执行

    mi.Invoke(p,null);

2、控件之间调用

    //获得父页面

    Page p =this.Parent.Page;

    //获得父页面的子控件

    UserControl uc = p.FindControl("hidTag") as UserControl;

    Type pageType = uc.GetType();

    //父页面的方法名

    MethodInfo mi = pageType.GetMethod("SaveBill");

    //执行

    mi.Invoke(p,null);

 

 

转载于:https://www.cnblogs.com/Elaine1133/p/5543048.html


最新回复(0)