How to Register a Control for Application-Wide Use
Most users know that if you want to use a custom server or user control on an
ASP.NET page, you need to register it first. This is normally done via a
<%@ Register %> directive at the top of the page. You're
probably familiar with the syntax:
This method works well, but can be somewhat cumbersome if you'll be using the
control on a number of pages. If you'll be using the same control
throughout your application, you can actually register it in your web.config
file. This alleviates the need to register the control on each and every page
and makes management much easier if you ever decide to move the control's source file.
The web.config section we'll be using is:
configuration -> system.web -> pages -> controls
Once you register a control here, you can then use it on any page within your application
without the need to include the <%@ Register %> directive at the top of the page.
This works on ASP.NET 2.0 and later and trust me... once you start using it you won't look back.
If you have a tip you would like to submit, please send it to:
webmaster@asp101.com.