title: How to build ASP.NET MVC user controls into class libraries
body: <p>I'm trying to build some .ascx controls into a class library for plugins for a CMS I'm building.</p>
  
  <p>My project type is a typical C# class libary with references added for system.web.mvc &amp; friends.</p>
  
  <p>My problem arises in trying to create a strongly-typed user control.  My control looks like this:</p>
  
  <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;TagCloudWidget.Models.TagCloudWidgetData&gt;" %&gt;
  </code></pre>
  
  <p>Even though I have another public class in the same project under the namespace <code>TagCloudWidget.Models</code>, I can't seem to get the <code>.ascx</code> file to recognize this.  I've tried including <code>Imports</code> for the namespace, but then it just complains that the namespace doesn't exist.  The TagCloudData class file looks like this:</p>
  
  <pre><code>namespace TagCloudWidget.Models
  {
  public class TagCloudWidgetData
  {
      public IList&lt;TagCount&gt; TagCounts { get; set; }
      public ContentTypes ContentType;
      public string Controller;
      public string Action;
  
      public TagCloudWidgetData(IList&lt;TagCount&gt; tagCounts, ContentTypes contentType, string controller, string action)
      {
          TagCounts = tagCounts;
          ContentType = contentType;
          Controller = controller;
          Action = action;
      }
  }
  }
  </code></pre>
  
  <p>Can you see what I'm doing wrong?</p>
  
  <p>Since the suggestion below, I've tried adding a code-behind file.  I think I'm closer to figuring out what's wrong, but I'm still not able to find a solution.  In the project, I've added references to System.Web and System.Web.Mvc.  But, in the using section of the codebehind file, when I type "using System.", auto-complete doesn't even show System.Web or System.Web.Mvc as available options.  It's like they just don't exist on disc.  Other projects are able to include them and reference them just fine.  I suppose this is the source of my problem, so I'm hopeful once I figure this out the rest will just fall into place.  Ideas?</p>