Nifty ASP.NET 2.0 Custom Control Tip

From Steve Smith:

One very cool feature of Visual Studio 2005 is that you no longer need to build your controls into separate assemblies.  You still *can* and of course if you're a control vendor or if you want to share them, you probably should, but if you just need a control in a single web application, you can drop the class into the /App_Code/ folder and immediately use it on your pages.  The even cooler part is you don't have to add a <%@ Register %> directive!  The “trick” to get this work is in the web.config file.  Add this section:

    <add tagPrefix="ss" namespace="DateControls" />

Once you have this, you can go to any of your pages and reference the control like so:

<ss:MonthDropDownList ID="Month" runat="server" />

Thanks to ScottW for reminding me how this works today...


Comments (0)

Skip to main content