error CS0103: The name 'txtReferralCode' does not exist in the current context
<p>I'm about ready to pull my hair out over this. I'm working on an ASP.NET 2.0 website in VS2010 and I'm getting the error you see in the title. The error only appears when I attempt to publish the website. If I simply right click the aspx file that it's in and click "View in Browser" it works perfectly fine. It also works fine if I run the file in debug mode from VS2010. There are other asp controls in the code that work perfectly fine, but for whatever reason, the one I've added has a problem.</p>

<p>Here's some of the relevant code:</p>

<p>c#:</p>

<pre><code>public partial class ApplicationScreen1Hold : System.Web.UI.Page
{
....
    protected void Page_Load(object sender, EventArgs e)
    {
    ....
         if (Request.QueryString["SID"] != null) //this is existing code
         {
             hdnSID.Value =  Request.QueryString["SID"].ToString().Trim();
          }
         if (Request.QueryString["RID"] != null) //this is my new code
         {
             txtReferralCode.Text = Request.QueryString["RID"];
         }
    ....
    }
}
</code></pre>

<p>html:</p>

<pre><code>&lt;td style="padding-left:25px"&gt;
    &lt;label&gt;Referral Code
         &lt;asp:TextBox ID="txtReferralCode" runat="server" MaxLength="8"&gt;&lt;/asp:TextBox&gt;
    &lt;/label&gt;
&lt;/td&gt;
</code></pre>

<p>In the c# code, I left in the line above to show how one of the other inputs in the same form is accessed with no issues. The text box control in the html I had copies from another text box on the page and changed the <code>id</code> and removed the <code>class</code> and <code>onkeyup</code> event as they weren't needed.</p>

<p>Is it possible I need to define the text box and I've just not found the where it does it for other controls or am I likely missing something else?</p>

<p>I've looked at the other questions which have referenced this error code but none of them have been able to help me.</p>
