Welcome to AspAdvice Sign in | Join | Help

Whidbey Controls in App_Code Folder

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:

<system.web>
  <pages>
   <controls>
    <add tagPrefix="ss" namespace="DateControls" />
   </controls>
  </pages>
...
</system.web>

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...

Published Wednesday, April 20, 2005 1:00 AM by ssmith
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Whidbey Controls in App_Code Folder

Very nice, this saved me from including a few dependencies and will make my solution a lot easier to maintain. My initial attempt to get this to work failed, but then I added the ToolboxData attribute to my control and it worked great. A walkthrough can be found at http://msdn2.microsoft.com/library/yhzc935f(en-us,vs.80).aspx.
Thursday, May 05, 2005 4:30 PM by ssmith

# 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...
Thursday, April 28, 2005 4:08 PM by TrackBack

Leave a Comment

(required) 
required 
(required) 
Enter the code you see below