title: Custom UserControl is not registering in ASP.NET
body: <p><strong>Update:</strong> J0e3gan tried my code in his own project, and it worked fine (with a minor correction), so the problem appears to be with Visual Studio itself, rather than the code or markup. I have tried adding a new <code>UserControl</code> as well, and it was not recognized either. However, VS is recognizing the <code>AjaxControlToolkit</code> that is registered in <code>web.config</code> just fine. <strong>[/update]</strong></p>
  
  <p>I'm trying to add a custom <code>UserControl</code> named <code>AdminControls</code> to the site I'm working on, but I keep getting the following error:</p>
  
  <blockquote>
    <p>Element 'ControlName' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.</p>
  </blockquote>
  
  <p>I'm running Visual Studio Pro 2013, and the project is a Web Application. I have searched the Web for solutions, mostly here on Stack Overflow, and have tried every one I could find, but have had no luck. There must be something I'm missing.</p>
  
  <p>Here is the markup for <code>AdminControls</code>:</p>
  
  
  
  <pre><code>&lt;asp:Table ID="tblAdminControls" runat="server"&gt;
      &lt;asp:TableRow&gt;
          &lt;asp:TableCell style="min-width: 50%;"&gt;&amp;nbsp;&lt;/asp:TableCell&gt;
          &lt;asp:TableCell style="width: 6em" id="tdCP" runat="server"&gt;
              &lt;asp:Button Font-Bold="true" Font-Size="Smaller" Font-Overline="false" ID="btnCP"
                  runat="server" CssClass="Button" Text="Control Panel" /&gt;
          &lt;/asp:TableCell&gt;
          &lt;asp:TableCell style="width: 5em"&gt;
              &lt;asp:Button Font-Bold="true" Font-Size="Smaller" Font-Overline="false" ID="btnLogOut"
                  runat="server" CssClass="Button" Text="LogOut" /&gt;
          &lt;/asp:TableCell&gt;
      &lt;/asp:TableRow&gt;
  &lt;/asp:Table&gt;
  </code></pre>
  
  <p>And here is the codebehind for it:</p>
  
  <pre><code>Public Class AdminControls
      Inherits System.Web.UI.UserControl
  
      Private Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
          If Request.ServerVariables("SCRIPT_NAME") = "/frmAdminCP.aspx" Then
              tdCP.Visible = False
          End If
      End Sub
  
      Private Sub btnCP_Click(sender As Object, e As EventArgs) Handles btnCP.Click
          Response.Redirect("frmAdminCP.aspx", False)
      End Sub
  
      Private Sub btnLogOut_Click(sender As Object, e As EventArgs) Handles btnLogOut.Click
          Session.RemoveAll()
          Session.Abandon()
          Response.Redirect("frmLogin.aspx", False)
      End Sub
  End Class
  </code></pre>
  
  <p>I've tried registering <code>AdminControls</code> both in the <code>web.config</code> file and on the page. Here's the relevant bits from the <code>web.config</code> file:</p>
  
  <pre><code>&lt;pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"&gt;
     &lt;controls&gt;
        &lt;add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" /&gt;
        &lt;add tagPrefix="klc" tagName="AdminHeader" src="~/AdminControls.ascx" /&gt;
     &lt;/controls&gt;
  &lt;/pages&gt;
  </code></pre>
  
  <p>And last but not least, here's one of the pages I'm trying to put <code>AdminControls</code> in:</p>
  
  <pre><code>&lt;%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
      EnableEventValidation="false" Inherits="ProjectName.frmAdminCP" CodeBehind="frmAdminCP.aspx.vb" %&gt;
  
  &lt;%@ Register TagPrefix="klc" TagName="AdminHeader" Src="~/Controls/AdminControls.ascx" %&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"&gt;
      &lt;div id="content"&gt;
          &lt;h1&gt;Admin &lt;span class="pagetitle"&gt;Control Panel&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/h1&gt;
          &lt;klc:AdminHeader runat="server" id="ahControls" /&gt;
          &lt;div&gt;
              &lt;h2&gt;Users&lt;/h2&gt;
              &lt;a href="frmUserList.aspx"&gt;View Existing Users&lt;/a&gt;&lt;br /&gt;
              &lt;a href="frmUserMod.aspx"&gt;Add a New User&lt;/a&gt;
              &lt;h2&gt;Usage Reports&lt;/h2&gt;
              &lt;a href="frmReportTrack.aspx"&gt;View User Activity Report&lt;/a&gt;&lt;br /&gt;
              &lt;a href="frmProjectLog.aspx"&gt;View Administrative Log&lt;/a&gt;
              &lt;h2&gt;Project Management&lt;/h2&gt;
              &lt;a href="frmProjectList.aspx"&gt;View Projects&lt;/a&gt;&lt;br /&gt;
              &lt;a href="frmDocManagement.aspx"&gt;Manage Project Files&lt;/a&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>I have attempted every fix I've come across, even if they seemed ridiculous.  I've:</p>
  
  <ul>
  <li>Purged the schema cache.</li>
  <li>Cleaned and rebuilt the solution.</li>
  <li>Restarted Visual Studio.</li>
  <li>Restarted my computer.</li>
  <li>Moved the file to a subdirectory.</li>
  <li>Cut and pasted the code and markup to the same place and resaved the files.</li>
  </ul>
  
  <p>There are no build errors, and the <code>tagPrefix</code> does not appear in the Intellisense auto-complete dropdown.</p>
  
  <p>Can anyone see any errors I've made, or does anyone know of a solution I haven't tried yet? I haven't tried slaughtering a black rooster over my PC yet, but I'm getting close.</p>