title: Add custom user control to published web project
body: <p>I am beginning to wonder if this is even possible.  It just seems so simple.</p>
  
  <p>I have a published web project.  I want to add some .ascx files (with .cs &amp; designer.cs files) to that published web site.  These are simple custom user controls that access methods already part of the original application.  </p>
  
  <p>Question? Is it possible to just drop these in the published web project without building the entire solution?  If not why?</p>
  
  <p>When I drop these files in and run my application I get the error:
  "Parse Error: Could not load type 'the name of my custom controls namespace'".</p>
  
  <p>There is not a lot of code to show so this is all I have.</p>
  
  <p>Default.aspx</p>
  
  <pre><code>&lt;%@ Page Language="C#" MasterPageFile="~/MasterPages/TwoColumn.master" AutoEventWireup="true"
      Inherits="ApplicationName.Web.Default" CodeBehind="Default.aspx.cs" %&gt;
  
  &lt;%@ Register TagPrefix="uc1" TagName="CustomControl" Src="~/Controls/Custom/CustomControl.ascx" %&gt;
  &lt;asp:Content ID="content" contentplaceholder="cph" runat="Server"&gt;
  &lt;uc1:CustomControl ID="cc1" runat="server" CustomProperty="Hello World" /&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>CustomControl.ascx</p>
  
  <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustomControl.ascx.cs"
      Inherits="ApplicationName.Web.Controls.Custom.CustomControl" %&gt;
  &lt;asp:PlaceHolder ID="ph1" runat="server&gt;&lt;/asp:PlaceHolder&gt;
  </code></pre>
  
  <p>CustomControl.ascx.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  
  namespace ApplicationName.Web.Controls.Custom
  {
  public partial class CustomControl : System.Web.UI.UserControl
  {
  ///My logic
  }
  }
  </code></pre>
  
  <p>Again it seems so easy.  What am I missing? Or is this not possible?  Thanks.</p>
  
  <p><strong>UPDATE:</strong>
  I figured this out.  The above scenario is possible.  The problem is not with the name-space as the error message suggests.  Rather it is the code-behind declaration.  Code-behind files for any type of file are compiled when the application is published.  I am still confused as to why it appears to be editable when you browse through a web directory, I would think it would be stored in a .dll file or something.  Maybe someone can shed some light on this.</p>
  
  <p>Anyways, replacing code-behind with code-file rectifies the problem as code-files are not compiled and are therefore readable at application run-time.</p>
  
  <p>Some links that were helpful can be found <a href="https://stackoverflow.com/questions/73022/codefile-vs-codebehind">here</a> and <a href="http://forums.asp.net/t/928924.aspx?PageIndex=2" rel="nofollow noreferrer">here</a>.</p>