Monday, March 17, 2008

How to Access UserControl from shared code in VS2005?

If you use the standard model - web site with App_Code directory, you could access a UserControl if you implement an interface that also belongs to App_Code. This is because asp.net compiles App_Code in one assembly, and the other folders (or every single page/control) in other assemblies. Other ugly way to do this is by using reflection, which I do not recommend. The best way is to migrate to Web Application Project which is very similar to the old good time of VS2003 projects that we all are used to. This goes with service pack 1 of the studio. You get a single assembly and thus all your pages and controls are visible to your utils classes.

No comments:

eXTReMe Tracker