Tuesday, June 24, 2008

How to Register User Controls and Custom Controls in Web.config

Asp.net 2.0 makes control declarations much easier to manage.Instead of duplicating them on all your pages.just declare them once within the new pages-->controls section with in the web.config file of your application.

<?xml version="1.0"?>

<configuration>

<system.web>

<pages>
<controls>
<add tagPrefix="bala" src="~/Controls/Header.ascx" tagName="header"/>
<add tagPrefix="bala" src="~/Controls/Footer.ascx" tagName="footer"/>
<add tagPrefix="ControlVendor" assembly="ControlVendorAssembly"/>
</controls>
</pages>

</system.web>

</configuration>




<strong>Output:</strong>

<html>
<body>
<form id="form1" runat="server">
<bala:header ID="MyHeader" runat="server" />
</form>
</body>
</html>