views:

220

answers:

2

Hi,

I am looking creating some custom controls that need to be compiled as a stand alone dll rather than with the primary application. Unfortunately so far this has meant manually creating the controls without the use of the designer since afaik you can't compile a User Control as a stand alone component. As doing things this way makes the controls rather difficult for the designers to style without putting in a lot of effort on the developers part, I am wondering if there is in fact a viable way to compile a .ascx style control into a stand alone binary?

+3  A: 

You can turn a user control into a custom control that is in a standalone .dll, but it loses the ability of being updateable via markup.

In other words, you can build an .ascx file using markup and code, and then turn it into something similar to a control that was built exclusively with code.

Turning an .ascx User Control into a Custom Control

You have to understand that user controls are just a convenience for reusable content though - ultimately, the markup does get processed and compiled. Custom controls are really the only way to distribute a web control. IF you have to distribute controls as a library, I would concentrate on making them CSS friendly for your devs with just a few layout controlling properties, rather than messing around with .ascx.

womp
When you use the mentioned technique, the naming of the DLL files is terrible. To fix that, use `aspnet_merge <yourdeploydir>` from the commandline without options. This will turn each directory into one DLL with all ASCX under it: http://msdn.microsoft.com/en-us/library/bb397866.aspx
Abel
+1  A: 

The MSDN article http://msdn.microsoft.com/en-us/library/aa479318.aspx explains how you can do this. Basicly you precompile the application and take the resulting DLL.

olle