Find component at run-time
-
I'm working on a server control that needs to find components (i.e., real instances that inherit from Component and not from WebControl) by name at run-time. At design-time, I would use ISite.Container.Components to do this very thing. But at run-time, ISite is null. I'd also try to use the WebControl.FindControl method but it only finds controls, not components. Does anybody know of a way to find a component at run-time? Sean Winstead
-
I'm working on a server control that needs to find components (i.e., real instances that inherit from Component and not from WebControl) by name at run-time. At design-time, I would use ISite.Container.Components to do this very thing. But at run-time, ISite is null. I'd also try to use the WebControl.FindControl method but it only finds controls, not components. Does anybody know of a way to find a component at run-time? Sean Winstead
Sean Winstead wrote: At design-time, I would use ISite.Container.Components to do this very thing. But at run-time, ISite is null. Hi Sean, You were very close with this, but the code should be
this.Container.Components
(in c# anyway). You can then loop around this count times until you find the ID of the control you want. Hope this helps, Simon.