• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 394
  • Last Modified:

Get Controls from Control Template ASP.NET

Hi All,

I have a very strange problem from my point of view.

I have created a Control with a Control Template. It only have one ControlTemplate which is Content.

I create a new instance with this code:

<mc:ContainerWindow runat="server" id="ContainerWindow1">
<asp:DropDownList runat="server" id="DropDownList1"></asp:DropDownList>

Now I want to get the dropdownlist from codebehind.
I then try to debug and step into my method which return the control, this works fine and I get the object returned.
If I on the other hand try to debug and step over the method, I get a NullReferenceException.

The method is overiding FindControl and return FindControl on the datacontainer I use to instatiateIn.

My questions is now:
Why is there a difference between step into and step over?
How can I get the control from the ControlTemplate?

I have used this link: http://msdn.microsoft.com/en-us/library/aa478964.aspx I have just extended it a bit, please ask If you need some code supplied.

Thanks in advance.
1 Solution
munchimanAuthor Commented:
Never mind.

My problem was caused by missing call to EnsureChildControls

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now