Reference Custom Controls Located In App_Code Folder

You can add references to assembly namespaces in your web.config to avoid having to register controls on every .aspx in your web site:

<system.web>
    <pages>
        <controls>
            <add tagPrefix="ajax" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>


... 

If you have a custom control located in your site's App_Code folder however, the assembly name is generated at compile-time. If you want to reference controls in the App_Code folder, just use "App_Code" as the assembly name:

<system.web>
    <pages>
        <controls>
            <add tagPrefix="jg" namespace="JamesGoodfellow.Web" assembly="App_Code"/>


... 

You can also choose to leave out the assembly attribute entirely - the compiler will try find the namespace in the App_Code assembly by default. I prefer to specify "App_Code" to eliminate potential confusion as to where  the control is located. 

Jimmy

Related posts

Comments

Add comment


 

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

September 9. 2010 08:41

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010