Tuesday, April 15, 2008

Web Part Class/Assembly Details

Many times you would like to know the assembly details and class name of a webpart. Now you can ask why you need to know these details. This is why! for example you are trying to dynamically trying to add some webparts on a page. To add these webparts you will first have to load the assembly and then have to create an instance of that webpart class through reflection. Now to load these assemblies and to create instance of webparts from webpart gallery you need to know there full 4 part assembly name and class name.

This is how! Try to add this webpart on your page through EditPage action. Once you have added you can now Export this webpart and open the .webpart file in a notepad. There you will see something like this:

'<'assembly'>'Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'<'/assembly'>' '<'typename>Microsoft.SharePoint.Portal.WebControls.QuickLinksMicroView'<'/typename'>'


Here Typename is the class name of the webpart. And this is for a My Links webpart. This will come handy manytimes when the name of Webpart class is different from the name in webpart gallery (Which is the case most of the time)

No comments: