Do you have a user control or a custom server control that you use in all your pages? Did you know that instead of registering the control on each and every page using:
<%@ Register TagPrefix="ucYouth" TagName="YouthInfo" Src="~/controls/YouthInfoUserControl.ascx" %>
You can register the controls in your web.config.
Under <Configuration><System.Web> add the following sections to register your controls site wide.
<pages>
<controls>
<!--Register custom user controls-->
<add tagPrefix="tgp1" tagName="tagName" src="~/controls/myFirstUserControl.ascx"/>
<!--Register custom server controls --assembly name is without extension (.dll)-->
<add tagPrefix="tgp2" assembly="assemblyName" namespace="assemblyNameSpace"/>
</controls>
</pages>
You can now use any of the controls in any page in your site - without having to register them on the page.
No comments:
Post a Comment