We have several web user controls in one of our sites. These controls are all placed in a \Controls sub directory. Many controls are created runtime and added to placeholders in the page. When we build this particular site (currently uses ASP.Net 3.5) we used to get this
The type or namespace name ‘Controls_XXXXX’ could not be found
(are you missing a using directive or an assembly reference?)
And design time Visual Studio was somehow not aware of these control’s classes!
Today I stumbled upon this MSDN link, addresses this very issue.
Essentialy what it says is to add class name to your controls ascx file’s directive:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PickList.ascx.cs" Inherits="Controls_PickList" ClassName="Controls_PickList" %>
And use Reference directive in your page where you use these control…
<%@ Register src="Controls/PickList.ascx" tagname="PickList" tagprefix="uc1" %>
Even if you are programmatically using these controls…
Cold case solved!!