Bizarre Problem Using a Custom User Control as a Delegate

I was creating what I thought was a very simply custom user control to be deployed as a delegate in order to enable custom analytics on a SharePoint site.  Everything came together quickly and I deployed the solution via Visual Studio, reloaded the site but my custom control was nowhere to be found.

The custom control’s ASCX file is deployed to a subfolder of the CONTROLTEMPLATES folder as per best practices but no matter what I did the control would not load.  The ULS logs showed the theoretically simple “User control “~\_controltemplates\Analytics\FooterCalls.ascx” is not in safe control list.”.  I rechecked everything related to SafeControls, directories, features, activation and deployment but everything was as it should be.

It turned out that the problem had nothing to do with SafeControls but was actually in my Elements.xml file where I was activating the control as a delegate.  The line that was causing the issue was:

<control id="FormFooter" sequence="110" controlsrc="~\_controltemplates\Analytics\FooterCalls.ascx" />

This particular portion of SharePoint is apparently very sensitive to the direction of the slashes.  Changing them to forward slashes fixed the problem.

<control id="FormFooter" sequence="110" controlsrc="~/_controltemplates/Analytics/FooterCalls.ascx" />

Hopefully this will save someone the hours I spent tracking this less than obvious fix down.

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 )

Connecting to %s