views:

65

answers:

1

I recently inherited a project that was done with the "web site project template" (which I hate by the way). I have always worked with the "web application template" which I love. I'm perplexed by something that I found in the project though. There is custom control instances throughout all the pages like this:

<cc1:MarketingItem runat="server" ID="BannerAd" />

Nothing too fancy there, right? What really irritates me is that it works just fine without any control registration tags at the top of any of the pages for "cc1" or code behind it's just magic! As you can imagine this makes tracking down the locations of these controls more work, and frankly a pain. My question is how is this even possible? And why did Microsoft introduce such an annoying inconsistency with this project template?

+3  A: 

You'll likely find it registered in web.config (system.web>pages>controls i believe). You can globaly register controls there just as you would on the page.

<pages>
  <controls>
    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  </controls>
</pages>
Josh
That was it, thanks.
James
Does this also work for the web application project template as well?
James
Yeah. I meant to come back in and mention that! It's very handy if you have a class library several pages will need!
Josh