ASP.NET: Registration of Controls in Web.Config
Apr 3, 2006 • Chris Pietschmann • ASP.NETIn ASP.NET 1.x controls had to be registered in each page they were used. New since ASP.NET 2.0, controls can be registered in the web.config file. Visual Studio 2005 supports full intellisense when editing .aspx pages. This feature allows commonly used controls to be more easily used through out your application.
Web.Config
<system.web>
<pages>
<controls>
<add tagPrefix="mycontrol" src="~/Controls/Header.ascx" tagName="header"/>
<add tagPrefix="mycontrol" src="~/Controls/Footer.ascx" tagName="footer"/>
</controls>
</pages>
</system.web>
Use the control in an .aspx page
<mycontrol:header id="Header" runat="server" />
Chris Pietschmann
Cloud Infra & Security | Microsoft MVP | HashiCorp Ambassador | MCT | Developer | Author
I am a solution architect, SRE, developer, trainer and author. I have nearly 25 years of experience in the Software Development industry that includes working as a Consultant and Trainer in a wide array of different industries.




