A Cold Case Solved !


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
error message…
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.

http://msdn.microsoft.com/en-us/library/c0az2h86.aspx

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!!
Phew!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s