Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

Updated

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:

http://eswar-prakash.com/blog/sharepoint-2007/sharepoint-rendering-templatesan-implementation

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.

share|improve this question
2  
if you found the answer yourself, can you use the answer box instead of updating your question ? this will permit you to mark the question as answered, and correctly return the question as answered in the site –  Steve B Jul 6 '11 at 9:41
    
As @SteveB says, can you please move the text from the "Updated" part of your question into an answer? It can then be marked as the answer. –  Alex Angas Jul 6 '11 at 10:17
    
Unfortunately I am not able to add the answer yet as I have less than 100 points. When I tried to add this answer, I was told I had to wait 8 hours. –  PeterM Jul 6 '11 at 10:23

1 Answer 1

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:

http://eswar-prakash.com/blog/sharepoint-2007/sharepoint-rendering-templatesan-implementation

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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