Get Controls from Control Template ASP.NET

Posted on 2009-04-23
Last Modified: 2013-11-08
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: I have just extended it a bit, please ask If you need some code supplied.

Thanks in advance.
Question by:munchiman
    1 Comment

    Accepted Solution

    Never mind.

    My problem was caused by missing call to EnsureChildControls

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now