Tuesday, 2 December 2008

Registering User Controls in the web config

To save having to register your user controls at the top of the page in .net 2.0 you can register them in the web.config. It also means if you change the location of your usercontrol you only need to change it in one place. It shows up in intellisense but it seems to want the control nodes in the web.config to be the first entry in the pages node.

<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="uc" tagName="AdviceStep1" src="~/Applications/Advice/Controls/AdviceStep1.ascx"/>
</controls>

No comments: