Troubleshooting the DelegateControl
Posted
Thursday, April 2, 2009 12:28 PM
by
CoreyRoth
I’ve have been using SharePoint’s DelegateControl a lot again lately. If you are not familiar with it, it allows you to drop a placeholder on a page and then later specify what control goes in it by activating a feature. You can effectively use it as an alternative to the SmartPart for putting user control’s on pages when you are deploying custom pages (i.e.: in a site definition or via publishing). However, one thing I have discovered is that if something goes wrong with the delegate control, there is absolutely zero feedback on the page to let you know that your control could not be loaded. It simply just displays the page without your control.
This is pretty annoying, but it is pretty easy to figure out what the issue is. As I have said many times in the past, the LOGS folder in the 12 hive is your friend. Most issues you have in SharePoint can be resolved by taking a look at this folder. For my latest issue, I opened up the latest log file, to find the following entries.
04/01/2009 14:56:21.98 w3wp.exe (0x6DA4) 0x6980 Windows SharePoint Services General 8e1n High Failed to create a user control from virtual path '/_ControlTemplates/MyControls/MyControl.ascx': Type 'System.Web.UI.WebControls.ListView' does not have a public property named 'ItemSeperatorTemplate'.
As you can see in my case, I was stupid and misspelled ItemSeparatorTemplate on my ListView control. This caused my control to throw a runtime exception. In a way I guess you can argue that this is nice, because the DelegateControl caught the exception and the entire page didn’t die with a yellow screen. However, it would be nice if the error could be reported without having to dig through the LOGS folder. Just remember any unhandled exception your user control might throw will cause the delegate control to display nothing. If you want more information on the DelegateControl, MSDN has some decent information on it.
Follow me on twitter.