null object reference in master pages
<p>I have some controls inside my master page, and i want to acces them from its related c# clas..</p>

<p>For instance i have:</p>

<pre><code>&lt;asp:DropDownList ID="ddlSearch" runat="server" 
                 onselectedindexchanged="ddlSearch_SelectedIndexChanged" 
                AutoPostBack="True"&gt;
            &lt;/asp:DropDownList&gt;
</code></pre>

<p>and i can acces it when writing code, so "it sees its properties ok".</p>

<p>But at runtime i received </p>

<blockquote>
  <p>Object reference not set to an instance of an object.</p>
</blockquote>

<p>Do u know why?</p>

<p>I also tried to find it like:</p>

<pre><code>ContentPlaceHolder mpContentPlaceHolder =
        (ContentPlaceHolder)this.FindControl("ContentHead");
    if (mpContentPlaceHolder != null)
    {
        DropDownList ddlSearch =
             (DropDownList)mpContentPlaceHolder.FindControl("ddlSearch");
        if (!Page.IsPostBack)
            utils.fillDDLSearch(ddlSearch);
    }
</code></pre>

<p>but it gives null too....which is really strange...</p>

<p>I tried with another object (an asp Image control, but exactly the same problem.
All it's ok at compiling time but gives null at runtime ALTHOUGH IT correctly finds out the content place holder.</p>

<p>Does anybody know the problem?</p>

<p><strong>The error:</strong></p>

<p><hr></p>

<p>Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.</p>

<p><hr></p>
