Welcome to EMC Consulting Blogs Sign in | Join | Help

Rory Street's EMC Consulting Blog (2004 - 2011)

This blog has now moved to http://rory.streetfamily.info - please update your subscriptions if you wish to receive new content.

SmartPart the easy way to develop SharePoint webparts

I finally got to make use of the Smart Parts Jan Tielens been working on, in a small project, and I must say they make developing SharePoint webparts incredibly easy. Create your usercontrols in a normal ASP.NET web applications and make sure they work by dragging them onto a ASPX page and running them (as you would with normal ASP.NET projects). Once you are happy with them drag the usercontrol into an unmanaged path on your sharepoint box and place the dll it generates into the sharepoint bin directory on your site. Once you have the SmartPart installed on your SharePoint box, drag them onto your page and then in the tool pane for there select your usercontrol...simple!

Now the above are some very simple steps you are told to follow when downloading the SmartPart from its GotDotNet  work space and the SmartPart is as Jan says an extension of Patrick Tisseghem method of using webcontrols in SharePoint development . The only problem I have found so far with SmartParts which is not the case with Patrick Tisseghems method of usercontrols with webpart development is that there is no access to the webpart base classes, however Jan informs me that this will change in the next release of the SmartPart. An example of what I am refering to, is if you tried to use an iCellConsumer method with a SmartPart this will work fine using an interface made available to you called the iCellProviderUserControl method as shown in Maxim V. Karpovs posting.

etc

public class MyUserControlClass : System.Web.UI.UserControl, iCellProviderUserControl 
{

     
  public string ConsumerMenuDescription
  {
   get
   {
    // TODO:  Add WebCustomControl1.ConsumerMenuDescription getter implementation
    return  "MyLabel";
   }
  }

  public string ConsumerMenuLabel
  {
   get
   {
    // TODO:  Add WebCustomControl1.ConsumerMenuLabel getter implementation
    return "MyLabelImp";
   }
  }

   /// This method consumes the data
   public void SetConsumerData(string val)
   {     

     localstring = val;

    }
}

tip: Hitting tab twice in Visual Studio after typing in iCellProviderUserControl will automatically create the Interface methods for you so you can set the labels for your properties. Remember to reference the SmartPart assembly.

However methods such as the iRowConsumer or iParametersInConsumer are not yet implemented. Another method that is not implemented that would be nice to have in a future release is the  UseDefaultStyles constructor. If anyone has had problems with styles on webparts in the past they will realise the importance of having this function which basically stops sharepoint from putting its own overriding style class around the webpart.

Alll in all, I love the SmartPart idea and think it has a lot more potential for future development. 

 

 

Published 23 January 2005 14:07 by rory.street

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server (Personal Edition), by Telligent Systems