
1.30.2006
Finding and Using User Controls in VS 2005
Joel at work had this issue today. How to LoadControl on an ASCX file that is in your project? Since the project deployment model is all new in VS 2005, the user controls are either not findable in the IDE (so no Intellisense), or not findable via LoadControl, since they are housed in the assemblies that have the unpredictable filenames.
Another problem that Paul pointed out is that User Controls that are in their own directory are not accessible from the aspx pages in the main directory. Presumably this is because of the new ASP.NET 2.0 compiler setup, where each directory is compiled into it's own assembly. So from the main project directory code-behinds, you can't reference the classes in another sub directory.
(A work around I came up with is to create the ASCX user control with no code-behind. It can then live in it's subdirectory and you can reference the properties, etc. on the user control class. Ugly that it has to be all code in the ascx file.)
ScottGu goes through a rather long walkthrough of how to accomplish this -- it's not pretty...
Building Re-Usable ASP.NET User Control and Page Libraries with VS 2005
Over at OdeToCode, K. Scott Allen shows a way to package ASCX controls for re-use using tweaks to the project file and using MSBUILD with ILMerge.
article here
Another problem that Paul pointed out is that User Controls that are in their own directory are not accessible from the aspx pages in the main directory. Presumably this is because of the new ASP.NET 2.0 compiler setup, where each directory is compiled into it's own assembly. So from the main project directory code-behinds, you can't reference the classes in another sub directory.
(A work around I came up with is to create the ASCX user control with no code-behind. It can then live in it's subdirectory and you can reference the properties, etc. on the user control class. Ugly that it has to be all code in the ascx file.)
ScottGu goes through a rather long walkthrough of how to accomplish this -- it's not pretty...
Building Re-Usable ASP.NET User Control and Page Libraries with VS 2005
Over at OdeToCode, K. Scott Allen shows a way to package ASCX controls for re-use using tweaks to the project file and using MSBUILD with ILMerge.
article here
Comments:
Post a Comment