Introducing "SmartPart for SharePoint"

Everyone who has created a webpart for SharePoint, knows that the “developer experience” is not as good as one would expect. You create the webpart in Visual Studio, based on the Webpart Template, but you can’t design the User Interface by drag-and-dropping controls on the webpart. But luckily you can use the “User Control technique” which gives the advantage that you can use the VS.NET UI designer. Patrick Tisseghem has evangelized this technique a lot, check out his article, his posts and the video. Fons Sonnema has written an article about how you can create and use a generic webpart that can host an ASP.NET User Control. I’ve extended this webpart with some extra functionality; let me introduce you to the SmartPart for SharePoint!

The SmartPart is a generic webpart that can contain an ASP.NET user control. Nothing new you would say, but the SmartPart can give your user control access to the SharePoint object model. So from within the code of the User Control you can do stuff with SharePoint! Another feature is that the user control can expose some properties which the SmartPart picks up, so the user can specify values for these properties in the SharePoint site. To prove you how easy it is, I’ve create a small demo. In this demo I will create a DropDownNavigation webpart in less than 5 minutes (it could be less, but I made some typos). The webpart will show a dropdown list in which the subsites of a SharePoint site are displayed. When a site is selected from the list, the user will be redirected to that site. Here’s the video.

First I create a new ASP.NET Web Application solution in Visual Studio.NET. Then I add a new Web User Control to the project. If you want to use the SharePoint object model, you need to add references to the SmartPart assembly and the SharePoint assembly. Next I add some code. When I’m done, I build the project (actually I try to build it, correct a mistake and build again). To be able to use the user control in SharePoint, I copy the assembly to the \BIN folder of my SharePoint site, and the .ASCX file to a newly created \UserControls folder. Finally I show how you can use the SmartPart webpart in SharePoint to load the newly created User Control.

Together with Fons, I’ve created a GotDotNet Workspace for the SmartPart. Over there you can download an installation package that will install the SmartPart, the source code and an example user control. At this point there isn’t very much documentation, but I will work on that. :-) There are a lot of cool ideas which (I hope) will be added to the SmartPart (for example a connectable SmartPart). I’ve IM-ed with Patrick today and he has another cool idea which he discussed in one of his latest posts: using the User Interface Process block together with web parts. Anyway, some nice ideas are waiting to be implemented!

21 Comments

  • Jan, you did a great job! It's way too cool! It's just so easy to hook up your ASP.NET user control with the smartpart. Just what we need! Now make them connectable! ;-)

    Again, Wow!

  • Wow, video. Great man!

  • What a great way to use .NET and SharePoint! I put an entry in my blog about this as well. Great work you two!

  • Great idea. Looking at the video, I only wish my laptop was just as quick at creating visual studio projects!!

  • You guys are amazing! This is what we have been waiting for. While we where waiting, you just developed it! Great solution to a huge problem.

  • Nice tool here...



    added to my blog

  • Is there anyway you could create an installer for the DropDownNavigation WebPart like you did for the Lead-It Navigation? That would be very helpfull, thank you.

  • Jan, you are doing some AMAZING work with SharePoint. I am positively in awe of all the cool stuff that's coming out of your mind. Rock on!

  • Just great, nothing more to say...

  • and smartpart shows (c:\windows\microsoft.net\framework\v1.1.4322\Config\machine.config line 198)

  • I am getting the below mentioned error .I have tried couple of times ...Any help will be highly appreciated.

    The "UserControlWebpart" Web Part appears to be causing a problem.



    Web Parts Maintenance Page: If you have permission, you can use this page to temporarily disable Web Parts or remove personal settings. For more information, contact your site administrator.


  • Cudos to you Jan this is a simple and most effective solution that you have developed. This has saved me weeks of potential hell. I owe you a beer!



    Cheers

  • Jan. This is great. I would like to incorporate WebPart Caching and Async into the SmartPart. Is there a way to get the latest source code? If not do you have any plans to add these features?

  • Jan. It is rare when I stop to write a comment so you have earned an award for getting a programmer out of a jam. Your articles have saved me on many occasions. LOL. Your smart webpart navigation article could have saved my organization thousand of dollars. You are an exception programmer.

  • Jan. This is a great tool. Its saved me lots of effort.
    I have a question. Is it possible to hide the Smartpart webpart control based on roles?

    Thanks in advance

  • Hii someone

    pls tell me how to reference stylesheet/ javascript file inside Smartpart..

    as smartpart does not contain head element, how can I link stylesheet?

    Pls pls help me someone

  • I have successfully developed and deployed the SmartPart Web Part and ascx file, but when I select the control for the Web Part I get the below error on the SharePoint page:

    The "SmartPart" Web Part appears to be causing a problem. Input string was not in a correct format.

    Any ideas or advice would be much appreciated!

    Many thanks

  • How can I download the smartpart now that gotdotnet is phased out?

  • Amy!

    Have you had any luck trying to link a stylesheet with SmartPart? I'm hitting my against this wall now.

    If anyone knows, TELL US! I'm still on SharePoint 2003 btw.

    Thanks!
    Larry

  • I am getting the below mentioned error while restoring a sharepoint site.I have tried couple of times ...Any help will be highly appreciated.
    The "UserControlWebpart" Web Part appears to be causing a problem.

    Web Parts Maintenance Page: If you have permission, you can use this page to temporarily disable Web Parts or remove personal settings. For more information, contact your site administrator.

  • Hi,
    in Real World SharePoint 2007 book at sample EmployeeGrid you use SmartPart v1.1.0.0 dll and the IConnectionProviderControl method but I can not find it so I use the ICellProviderUserControl which returns error during compiling. Also the side GotDotNet is being phased out.
    Do you have any idea what to do.....

Comments have been disabled for this content.