查找嵌套的用户控件

时间:2009-07-20 16:26:55

标签: asp.net

我在用户控件中有一个用户控件。我想使用用户控件#1从页面的代码隐藏引用嵌套用户控件。用户控件#1嵌套了usercontrol#1

2 个答案:

答案 0 :(得分:2)

您想从页面本身调用它,因此您必须在用户控件本身中公开嵌套的用户控件。

public Control NestedUserControl
{
  get{ return FindControl(nameOfUserControl);}
}

在页面后面的代码中只做:

UserControl1.NestedUserControl

答案 1 :(得分:0)

使用FindControl方法。

UseControl1.FindControl("IdOfNestedUserControl");
相关问题