How can I tell whether a webpart that has been deployed to a site is a native webpart that ships wit

Posted by program247365 on Stack Overflow See other posts from Stack Overflow or by program247365
Published on 2010-05-14T14:56:50Z Indexed on 2010/05/14 15:24 UTC
Read the original article Hit count: 293

I have a SharePoint 2007 MOSS instance, and I'm on a fact-finding mission. There have been multiple developers, developing multiple webparts and deploying them (using VS2005/2008 SharePoint Extensions).

I thought maybe I could look at the fields in the "Web Part Gallery" list in my site, and look by "Modified by", but it looks like a developer's name is on some of the out-of-the-box webparts somehow, and on ones I know are custom developed, they say "System Account" - so looking at that field in this list is a no go.

I thought then maybe I could look at the "Group" to which each webpart was assigned but it looks like they were arbitrarily assigned to many different groups inconsistently - so using that piece of information is a no go.

Here is my code I have for just looping through and getting the names of all the webparts. Is there any property I can access on the list items of webparts that would tell me whether it's a custom developed webpart? Any way to distinguish the custom webparts from the out-of-the-box ones? Is there another way to do this?

        #region Misc Site Collection Methods
        public static List<string> GetAllWebParts(string connectedSPInstanceUrl)
        {
            List<string> lstWebParts = new List<string>();

            try
            {
                using (SPSite site = new SPSite(connectedSPInstanceUrl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList list = web.Lists["Web Part Gallery"];
                        foreach (SPListItem item in list.Items)
                        {
                            lstWebParts.Add(item.Name);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lstWebParts.Add("Error");
                lstWebParts.Add("Message: " + ex.Message);
                lstWebParts.Add("Inner Exception: " + ex.InnerException.ToString());
                lstWebParts.Add("Stack Trace: " + ex.StackTrace);
            }

            return lstWebParts;
        }
        #endregion

© Stack Overflow or respective owner

Related posts about sharepoint

Related posts about sharepoint2007