views:

104

answers:

1

Hi all,

I know if someone wnats to re-use some classes (not UI), he must gather all of them and put in a Visual Studio Class Library, build it to some dells and distribute thoese dlls. In this approach there just one code, you just update code in one place.

But what about ASP.NET's markups? For exmaple you have an .ascx file or a collection of .aspx files regarding user managment. If I wnat to use them in another project I am forced to copy them in new project again. By this I have two same code that is very hard to maintain.

So is it any way to re-use .ascx and .aspx files just like simple .dlls? For example building them?

Many Thanks, Afshar Mohebbi

+3  A: 

With the default configuration, .ascx and .aspx files will need to exist on disk, because they need to have a path associated with them for everything to work. All the code (everything but the first line which specifies which class to inherit) in them, however, can be compiled away into a DLL file. It would probably be possible to get around this by writing custom handlers and build providers that load things from DLLs, but it's not worth the effort.

If you want to put your user controls into a DLL file, create them as custom controls instead of user controls (.ascx files). That's how all the custom control libraries for sale around the 'net are done.

Matti Virkkunen