Getting Latest Major Version for an SPListItem Variations sites and IIS virtual directories with same path cause site failure on app pool recycle
Sep 05

The SmartPart Report can be downloaded at http://www.codeplex.com/SmartPartReport

If you use SmartParts then you’ll know how messy that usercontrols folder can get.  Worse, if you’ve inherited a SharePoint project with many pages that has SmartParts used all over the site, most likely you’ll need to know where each user control is being used.  This is the reason I came about making the SmartPart report.

The code is pretty straight forward.  It basically loops through each file, looks for only aspx files, and then goes through each webpart and checks to see if the type is a SmartPart. 

 You could also expand upon this and search for other web part types as well.  For example if you wanted to also look for Microsoft.SharePoint.WebPartPages.ListViewWebPart you can add it to the searchWebPartTypes array on line 83:

                    string[] searchWebPartTypes = { “SmartPart.SmartPart”, “SmartPart.AJAXSmartPart” , “Microsoft.SharePoint.WebPartPages.ListViewWebPart” };

It then uses reflection to get the “UserControl” property for a SmartPart.  Again, if you’re using this to find another web part, you could put some conditions around this and modify the propertyname to get the value you’re looking for.  Ex:

line 97:

          string propertyName = “UserControl”;
          string userControlFileName = “”;
         
          if (webPartType == “Microsoft.SharePoint.WebPartPages.ListViewWebPart”)
          {
                propertyName = “Title”;
          
}

Leave a Reply