Create SharePoint Webparts With ASP.NET User Controls (+ Demo Video!)
Patrick Tisseghem loves creating SharePoint webparts using ASP.NET user controls, in one of his latest posts he simplifies this technique by using the dynamically compiled assembly (that is build the first time the user control is rendered on an ASP.NET page) which contains the user control. He even made a video that shows step-by-step how this works! Thanks Patrick for the free U2U course! ;-) I think this process could be even more simplified (as Patrick suggests) by using a utility that would compile the ASP.NET user control, without having to render that user control on a web form. I don’t know the compiler parameters that should be used to emulate what ASP.NET does, maybe someone else can help us out? My first experiences in a test environment were quite positive (after referencing the right assemblies :-). The procedure feels a little bit weird (you rely on ASP.NET to compile the user control), but there has to be a cleaner way to get a hold of the assemblies you need…
In a comment Renaud Comte describes even another approach to use user controls to create webparts. He compiles the user control as an embedded resource and uses a generic container. I’ve haven’t tried this technique, but if you’re intresed I recommend to read his blog post which also has a link to the full source code.