如何在 ASP.NET 中找到动态创建的用户控件的控件?

How to find controls on a dynamically created user control in ASP.NET?

我必须根据条件在动态创建的用户控件上禁用 link。

如何查找控件的类型? 我正在使用占位符,因此试图找到如下所示的控件 this.placeholder1.FindControl("usercontrol1").FindControl("div1");

如何在 UserControl1 类型的 usercontrol1 上找到 link? 我无法使用 .ascx 文件的名称 UserControl1。

  1. 您必须在每次回发时重新创建动态控件。

  2. 那么只有您可以使用

  3. 访问那些控件

var yourControll= (UserControlType) this.placeholder1.FindControl("usercontrol1");