I have managed to override one of the rendering templates that SharePoint uses that is defined in DefaultTemplates.ascx. I have placed the new .ascx file in the controlTemplates folder in the 12 hive (WSS 3.0). The customisation is just a simple message using an asp Label tag and the DefaultTemplates.ascx has not been modified.
It works just fine.
Here is my question then. How does SharePoint know that I have created a new template?
I imagine that it iterates all the files in the folder at startup as you have to IISReset (or reset app pool) each time you make a change, am I right?
I have been fortunate enough to find an answer that explains my question perfectly. These two paragraphs were copied directly from an article by Eswar Prakash, it is not mine at all. You can find the full article here:
When the first request for a template with an ID comes through to SPControlTemplateManager, all the UserControl files living within CONTROLTEMPLATES folder in the SharePoint Hive are parsed and all RenderingTemplate controls are initialized and are converted to ITemplate instances and cached within an internal static Hashtable with ID being the key. We must be aware that the class doesn’t parse through the sub-folders within the CONTROLTEMPLATES folder.
After initially loading the default template files, the caching mechanism proceeds to load other .ascx files living within the folder. If it finds templates with the same name as the default one (for e.g. ListForm) then the default one is overwritten with the newly loaded one. If you were to enable “Verbose” logging for the “Web Controls” category you will see trace entries in the ULS logs that explains which template was overridden by the ones in which file. This is the technique we will be using to override a document libraries editing form with our own.