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

1.1k Views Asked by At

I have to disable a link on dynamically created user control depending on condition.

How to find type of the control? I am using a placeholder, hence trying to find the control like below this.placeholder1.FindControl("usercontrol1").FindControl("div1");

How to find link on usercontrol1 of type UserControl1? I can't use the name UserControl1 of the .ascx file.

1

There are 1 best solutions below

1
Nick On BEST ANSWER
  1. You must recreate dynamic controls on each postback.

  2. Then only you can access those control using

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