0

I wanted to add a user control to a MasterPage. I added the control to a VS Solution and deployed it. Then I opened the MasterPage via SharePoint Designer and added the following code:

<%@ Register TagPrefix="uc0" TagName="LanguageChecker" Src="~/_controltemplates/Project/UserControls/LanguageChecker.ascx" %>

Now when I open a page that uses this .master I get the following error:

Server Error. The resource cannot be found.

When I looked at the page sorce it said:

The file /_controltemplates/Project/UserControls/LanguageChecker.ascx does not exist.

Of course it doesn't. The file path is missing the Site Url in the beginning.

I looked and found some possible problems. The only one that caught my attention was: SharePoint Designer might remove the "~/" from registration of the User Control in the master. I opened the designer again but the ~/ is there. I want to see the file itself, to check if the ~/ exists in it.

However the MasterPage has been added via the SharePoint Designer and I do not know where to look for the actual file. Is it on the Hard Drive?

I tryed to find the user control by it's Url(full, correct) and it's there.

I am using SharePoint 2010

1

If this is 2013 the path should be:

<%@ Register TagPrefix="uc0" TagName="LanguageChecker" Src="/_controltemplates/15/Project/UserControls/LanguageChecker.ascx" %>

So, remove the ~ and add /15 to the Src.

Your user control should be added to the Mapped folder CONTROLTEMPLATES in VS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.