使用C#反射实现用户控件调用父页面方法

using System.Reflection; 
MethodInfo mi =  this.Page.GetType().GetMethod("GetUserName"); //该处的GetUserName是父页面里的方法名称
        int userId=5;       
        return mi.Invoke(p, new object[] {userId}).ToString();  //userId指的指的是GetUserName所要传递的参数。

 

posted @ 2013-06-26 14:30  Micmacs  阅读(487)  评论(0编辑  收藏  举报