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.

9 Comments

  • Hi,



    I've tried to copy instructions in this video in Visual Basic.

    In this piece of code in my Calendar.vb:



    Private uc As New CalendarControl_ascx

    Protected Overrides Sub CreateChildControls()

    Me.uc = New CalendarControl_ascx

    Me.Controls.Add(Me.uc)

    End Sub



    It says: "Reference required to assembly 'DemoUserControls' containing the base class 'DemoUserControls.CalendarControl'. Add one to your project."



    I have done everything on the video, including the references to the dll and to my other project in the solution. Intellisense also suggests the "CalendarControl_ascx" in it's list, so it sees the reference there.

    I don't get it!

  • Hi

    I found the same problem that Martijn de Groot have.

    I do same proyect in C# and VB.Net.

    The C# work but vb don´t.



    any ideas to resolve it?



    thx!

  • Fontecha, Martijn: I don't have an idea to resolve this... :-(

  • try to replace CalendarControl_ascx

    with DemoUserControls.CalenderControl

  • try to replace CalendarControl_ascx

    with DemoUserControls.CalenderControl

  • I'm having problems proper displaying the webpart. I only get to see the titlebar, but no calendarcontrol. Can anyone tell me what I might be doing wrong. I'm working with VB.NET. Thanks!!

  • I am new to Web parts and wanted to know if I can build them with VS2005 for Sharepoint 2003 or can only VS2003 be used. Thanks. Video link is down but would like to know more.

    Roo

  • ietosnovamy 450617 http://mince.richandprivilegedtravel.com/mince-verre-vitres.html mince verre vitres mince verre vitres [URL=http://mince.richandprivilegedtravel.com/mince-verre-vitres.html]mince verre vitres[/URL] mince.richandprivilegedtravel.com/mince-verre-vitres.html [link=http://mince.richandprivilegedtravel.com/mince-verre-vitres.html]mince verre vitres[/link] * http://heroism.richandprivilegedtravel.com/a-mystery-of-heroism.html a mystery of heroism a mystery of heroism [URL=http://heroism.richandprivilegedtravel.com/a-mystery-of-heroism.html]a mystery of heroism[/URL] heroism.richandprivilegedtravel.com/a-mystery-of-heroism.html [link=http://heroism.richandprivilegedtravel.com/a-mystery-of-heroism.html]a mystery of heroism[/link] * http://heroism.richandprivilegedtravel.com/heroism_70.html heroism heroism [URL=http://heroism.richandprivilegedtravel.com/heroism_70.html]heroism[/URL] heroism.richandprivilegedtravel.com/heroism_70.html [link=http://heroism.richandprivilegedtravel.com/heroism_70.html]heroism[/link] * http://heroism.richandprivilegedtravel.com/ heroism heroism [URL=http://heroism.richandprivilegedtravel.com/]heroism[/URL] heroism.richandprivilegedtravel.com/ [link=http://heroism.richandprivilegedtravel.com/]heroism[/link] * http://mince.richandprivilegedtravel.com/coupe-mince.html coupe mince coupe mince [URL=http://mince.richandprivilegedtravel.com/coupe-mince.html]coupe mince[/URL] mince.richandprivilegedtravel.com/coupe-mince.html [link=http://mince.richandprivilegedtravel.com/coupe-mince.html]coupe mince[/link] * http://mince.richandprivilegedtravel.com/pork-mince.html pork mince pork mince [URL=http://mince.richandprivilegedtravel.com/pork-mince.html]pork mince[/URL] mince.richandprivilegedtravel.com/pork-mince.html [link=http://mince.richandprivilegedtravel.com/pork-mince.html]pork mince[/link] *

  • please send me the demo video

Comments have been disabled for this content.