Sunday, July 23, 2006

FW: SPS 2003 WebParts vs. ASP.NET 2.0 Webparts

ASP.NET 2.0 WebPart Framework is a new feature in 2.0. Although Webparts existed in SPS 2003 times, this framework is completely new and follows its own architecture. The cool thing is ASP.NET 2.0 webpart framework is now compatible with latest version of sharepoint
i.e MOSS 2007.
This means ASP.NET 2.0 webparts can be used in Sharepoint 2007.

I wont repeat here the steps required to use your ASP.NET 2.0 webpart in Sharepoint 2007. You can see several blogs on this topic like:

One main thing here to be kept in mind while creating custom webparts is that 2003 webparts dwp file uses different schema than Sharepoint 2007 webparts. If you try to use the ASP.NET webpart with old schema and try to import it in sharepoint you get the error:

The class does not derive from the Microsoft.SharePoint.WebPartPages.WebPart class and therefore cannot be
imported or used in a WebPartZone control

To resolve this ASP.NET webparts uses the different schema which is like this:


<?xml version="1.0" encoding="utf-8"?>
 <webPart xmlns="">
   <type name="aspwebpart.FeaturePart, aspwebpart, Version=, Culture=neutral, PublicKeyToken=null" />
   <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
    <property name="Title" type="string">FeaturePart</property>

Using this schema you can easily import your 2.0 webparts onto sharpeoint 2007.

The custom webparts you create can either be imported from
System.WEb.UI.WebControls.Webparts or Microsoft.Sharepoint.WebPartPages.Webpart

However if you plan to use feature like connections between webparts , you are left with
the option of using only deriving from Microsoft.Sharepoint.WEbPartPages.WebPart.


kick it on


The Penns said...

I am using the v3 dwp schema in a MOSS solution CAB package to deploy the web parts. The web part deploys, but when you go to add the web part to a page in MOSS, it shows up under Miscellaneous with the name {guid here}_MyDwpFile.dwp.

Any thoughts on how to set this name? Thanks.

The Penns said...

Madhur said...

did you set the title tag inside the dwp file.

I did. The DWP has the Title and Description property elements set under the properties element. It's almost as if something is missing from the manifest.

Anonymous said...

We struggled in embedding a webpart (.net) in Site definition/layout. Finally we rebuilt our webpart using sharepoint libraries :-(

Glad to see information on this in your blog. Though late, would be useful in next project

Anonymous said...

Saved my butt! THanks for the info, it was driving me mad!