I have an aspx page with an ajax tab container. In a class I want to find the tab container to pass some values.
I define myPage:
Page myPage = (Page)HttpContext.Current.Handler;
When looking in more details on this myPage by clicking add watch it is listing the tab container I am looking for. However when I define my tab container
AjaxControlToolkit.TabContainer Workflow_TabContainer = null;
Workflow_TabContainer =
(AjaxControlToolkit.TabContainer)myPage.FindControl("Workflow_TabContainer")
as AjaxControlToolkit.TabContainer;
or
AjaxControlToolkit.TabContainer Workflow_TabContainer
(AjaxControlToolkit.TabContainer)myPage.FindControl("Workflow_TabContainer");
it does not find the tab container. I also tried to first define the page, than the ContentPlaceholder and searched for the tab container in the place holder. Same issue.
Any help and/or hint is much appreciated.
Thanks
The
FindControlmethod only looks in the current control for children.If you don’t know where in the page hierarchy the controls are, you’ll need to do a recursive search – which is likely if you’re using a templated control such as the
TabContainer.As I’ve posted previously to a similar answer:
Once you’ve got your control, you should cast it using
asand then check for null just in case it’s not quite what you were expecting: