Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET UserControl Does Not Initialize Child Controls
    text
    copied!<p>Inside my page, I have the following:</p> <pre><code>&lt;aspe:UpdatePanel runat="server" ID="updatePanel"&gt; &lt;ContentTemplate&gt; &lt;local:KeywordSelector runat="server" ID="ksKeywords" /&gt; &lt;/ContentTemplate&gt; &lt;/aspe:UpdatePanel&gt; </code></pre> <p>The <code>KeywordSelector</code> control is a control I define in the same assembly and <code>local</code> is mapped to its namespace.</p> <p>The control is made up of several other controls and is defined as such:</p> <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeBehind="KeywordSelector.ascx.cs" Inherits="Keywords.KeywordSelector" %&gt; </code></pre> <p>and has quite a few server controls of its own, all defined as members in the <code>.designer.cs</code> file.</p> <p>However, <strong>during no part of the control's lifecycle does it have any child control objects nor does it produce HTML</strong>:</p> <ol> <li>All of the members defined in the <code>.designer.cs</code> file are <code>null</code>.</li> <li>Calls to <code>HasControls</code> return <code>false</code>.</li> <li>Calls to <code>EnsureChildControls</code> do nothing.</li> <li>The <code>Controls</code> collection is empty.</li> </ol> <p>Removing the <code>UpdatePanel</code> did no good. I tried to reproduce it in a clean page with a new <code>UserControl</code> and the same thing happens.</p> <p>I am using ASP.NET over .NET Framework 3.5 SP1 with the integrated web server.</p> <p>What am I missing here?</p> <p><strong>Update #1:</strong> Following Rob's comment, I looked into <code>OnInit</code> and found that the <code>UserControl</code> does not detect that it has any child controls. Moreover, <code>CreateControlCollection</code> is never called!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload