Search code examples
asp.nettemplatesupdatepanelservercontrols

ASP.Net Templated Server Controls difference between UpdatePanel and other controls


Using the advise given on this post...

Creating an ASP.Net Templated Server control

... I was able to create a nice templated server control.

However, what I noticed is that on some templated controls such as the ASP.Net UpdatePanel you dont need to use FindControl to find the actual control inside your template. UpdatePanel has a template (or similar) and this just allows dirrect access to your controls without using the FindControl method that I have to use on the templated control I have created.

How do I make my control like the update panel where no template is needed?

Thanks.


Solution

  • You use a template, but add [TemplateInstance(TemplateInstance.Single)] to the property with the ITemplate and that should solve that issue:

    http://msdn.microsoft.com/en-us/library/system.web.ui.templateinstanceattribute.aspx

    HTH.