File ~/_controltemplates/{someusercontrol}.ascx was not found

Today I stumbled upon something in VS2010 that I think is maybe a bug. I found a very simple workaround though, so I thought I´d share how I solved it.

I was working with a SharePoint 2010 solution in VS2010 that looked something like what you see in the image below (simplified for this example though):

The basic line-up is that I have a custom ascx control (aka User Control) and a page where I´m going to use the ascx control.
The ascx control lives in the “mapped folder” called CONTROLTEMPLATES as you can see.

The ascx has a code-behind file where I have a property (CustomString) that lets me set a text on a label in the ascx control.

Simple enough?


The problem

So in the aspx page I added a registration for the ascx file with the new resource picker for SharePoint in VS2010 that lets you pick files both in the VS solution tree and in the SharePoint root, which gave me the registration tag like below:

…and the VS gives me an error stating that it can´t find the ascx file. This of course makes VS unable to resolve the tag prefix for my ascx control and thus makes it impossible for me to use the custom property on the ascx control.


The solution

What´s up with this then. I have a mapped folder and I used the new resource picker…tools from Microsoft.

It´s really quite simple. The resource picker uses ~/_controltemplates (which is correct because that is how IIS will find the file) but the mapped folder is called CONTROLTEMPLATES (the VS ‘add new mapped folder’ command has named the mapped folder without an underscore in beginning…is this a bug or should VS be able to figure this out anyway?).

_controltemplates and CONTROLTEMPLATES is not the same path and hence, VS can´t find the file.

Rename the mapped folder to _CONTROLTEMPLATES since it´s just a name on a folder in VS.

And now VS will give me sweet intellisense again…




PS. The same problem probably exists with the all the mapped folder and files you reference, like LAYOUTS


, , ,

  1. File ~/_controltemplates/{someusercontrol}.ascx was not found
  2. the file '/_controltemplates/.ascx' does not exist

Leave a Reply

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

You are commenting using your 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

%d bloggers like this: