(Tutorial) Straight way to Create ASP.NET user controls library
Tutorial: Straight way to Create ASP.NET user controls library
My post-build tool transforming any Web Application into a library containing .ascx controls.
Preamble
I feel necessity to compile my ASP.NET user controls into a library. It is good for modularity and reusing. However, there is no official way to do it. We can create custom controls library only.
Note:- The difference between custom controls and user controls. Custom control is ordinary .NET class inherited from
System.Web.WebControls.WebControl. It overrides method RenderContents and renders itself with output.Write(...).
User control consists of *.ascx file, codebehind * .vb file and *.designer.cs file. It allows to simple write HTML code and uses all benefits of
code behind model. ASP.NET compiles it at runtime.
I researched many articles offering several workarounds like:-
* Copy wry DLLs (Asp_web_[control name].ascx.73dba69a.dll, etc ) + controls’ source into target project.
* Use wry IIS configuration to substitute foreign virtual directory.
* Create single DLL with ILMerge and use wry control names like
mycontrols_goodcontrol_ascx.
All these ways have seriously weakness. I have several requirements for straight way:
* Preserve designers, code generators, etc working within the library project
* It should be easy to use controls of the library in any other web application
* It should be easy to use controls of the library in other such libraries
* It should be easy to reuse controls of the library within itself
* It should be possible to reference the library as project
* It should be possible to reference the library as DLL
* The library should consist of one file.
* It should be possible to create new library in 30 seconds
* The solution should work for .NET v2.0, v3.0, v3.5
Courtesy: Codeproject.com
- guru's blog
- Login or register to post comments

