You can move your SpiffyControl into a library - this will give it a more precise namespace and also allow you to use it in other projects. This is a little complex, though - you have a UserControl already made, but it won't work in a library. UserControls use the codebehind model - they are composed of two files, one markup and one code. Libraries don't seem to support the codebehind model, so you can't use a UserControl. You need to convert that user control to a web control.
Create a new class library project. Open up the project's properties and set the AssemblyName and Default Namespace to SpiffyLibrary.
Now we need to convert your UserControl. First, create a class in your new library. Call it SpiffyControl, just like your existing user control, but make it inherit from System.Web.UI.WebControls.CompositeControl.
Second, open up the code for your existing user control and copy everything inside the class. Then go back to the new class and paste it all inside. If you're using any of the standard control events, you may need to rename those functions to override the appropriate events. For example,
protected void Page_Load(object sender, EventArgs e)
{
...
}
... should become ...
protected override void OnLoad(EventArgs e)
{
...
base.OnLoad(e);
}
Third (this is the complex part) you need to reproduce all the markup you had in SpiffyControl's markup file. You can't just copy it - instead, you need to override the CreateChildControls() function which is inherited from CompositeControl. Every tag you had in the markup needs to be instantiated like a variable and added to the class's Controls collection. So for example, if your existing markup file looked like this:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SpiffyControl.ascx.cs" Inherits="Controls_SpiffyControl" %>
<div id="Div1" runat="server">
<asp:Label ID="TextOutput" runat="server" />
</div>
... then your new CreateChildControls function should look like this:
HtmlGenericControl Div1;
Label TextLabel;
protected override void CreateChildControls()
{
Div1 = new HtmlGenericControl("div");
this.Controls.Add(Div1);
TextLabel = new Label();
Div1.Controls.Add(TextLabel);
base.CreateChildControls();
}
Note that the controls are declared as class fields; that way, they're visible to all the class methods.
Once you've converted your markup, compile the library project and add it to the references for your website project. Then open your website's web.config file and find the system.web / pages / controls section. This section should already have a tag like this:
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
That tag is what lets you use controls from the ASP core libraries. So we're going to add one just like it, for our library:
<add tagPrefix="spiffy" namespace="SpiffyLibrary" assembly="SpiffyLibrary" />
Now anywhere in your site, you can put in markup like this:
<spiffy:SpiffyControl ID="SpiffyInstance" runat="server" />
... and that will load your web control from your custom library.