Microsoft Most Valuable Professional

Chris Pietschmann

An MVP From Wisconsin



ASP.NET 2.0: Registration of Controls in Web.Config

In ASP.NET 1.x controls had to be registered in each page they were used. New to 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

[code:xml]
<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>
[/code]

Use the control in an .aspx page

[code:html]
<mycontrol:header id="Header" runat="server" />
[/code]

Currently rated 3.0 by 3 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: General
Posted by crpietschmann on Monday, April 03, 2006 10:36 PM
Permalink | Comments (2) | Post RSSRSS comment feed

Related posts

Comments

Raul Macias

Tuesday, April 11, 2006 12:14 AM

Raul Macias

What are the advantage/disadvantage of this new way of registering user controls (.ASCX)? Better performance?
Also, can custom server controls be registered in the same way?

Michal Talaga

Saturday, January 20, 2007 6:09 PM

Michal Talaga

The main advatage is that you can specify the same tagPrefix for each control. Doing that allows you to easily copy controls from one page to the other.

Comments are closed

About the author

I'm Chris Pietschmann, go to the About Me page to learn more about me.

Search

Sponsors

Web.Maps.VE - ASP.NET AJAX Virtual Earth Mapping Server Control

Recent comments

Disclaimer


This work is licensed under a Creative Commons Attribution 3.0 United States License, unless explicitly stated otherwise within the posted content.
© Copyright 2004 - 2008 Chris Pietschmann