Fly with the wind-TerryDong

.NET on the way
posts - 13, comments - 39, trackbacks - 1, articles - 0

2008年3月5日

两个UC:A.ascx ,B.ascx

在A中FindControl后B的类型是UsesrControl,是B父类,不能直接使用B中的自定义方法和属性,不过我们可以通过反射的方式可以在A中获取B中的所有信息并可以操作B的方法

 

demo code:

//get u2 instance

UserControl u2 = (UserControl)this.Parent.FindControl("UC2_1");

//set u2's properties

u2.GetType().GetProperty("relaType").SetValue(u2, relaType, null);
u2.GetType().GetProperty("relaInfo").SetValue(u2, relaInfo, null);
u2.GetType().GetProperty("Cust_ID").SetValue(u2, Cust_ID, null);

//operate u2's method

MethodInfo mi = u2.GetType().GetMethod("BindUC2");
mi.Invoke(u2, null);

 

看看效果吧。

posted @ 2008-05-12 14:54 Terry Dong 阅读(34) | 评论 (2)编辑

     摘要: 原文地址:http://www.codeproject.com/KB/aspnet/10ASPNetPerformance.aspx Introduction ASP.NET 2.0 has many secrets, which when revealed can give you big performance and scalability boost. For instance, ther... 阅读全文

posted @ 2008-03-05 10:30 Terry Dong 阅读(76) | 评论 (0)编辑