Registering a web part in SharePoint 2007 –

After struggling with this a couple different times, I’ve decided it’s worth documenting how to do this so I don’t have to go through the pain again.  Basically, once you have your web part compiled (See Mart Muller’s blog entry on how to create a web part) you need to:

  1. Add the web part assembly (the dll file) to the GAC by copying the dll file to the c:\windows\assembly directory.
  2. Designate the web part as a safe control in your web.config file.  This is the one that got me.  There are many web config files to choose from.  To determine which one should be updated I:
    • Opened IIS and found the web site I was working with.  
    • Viewed the properties of that web site
    • On the Home Directory tab, the Local Path field tells you where your web.config is stored.
  3. Add the web part to your site’s web part gallery.  The above steps ensure your web part is registered and designated as a safe control.  But when you try to add the web part to one of the web part zones in your page it won’t be in the list to select.  There’s one more step that needs to be done…add your new web part to the web part gallery.   Within your site;
    • Go to Site Actions| Site Settings |Modify All Site Settings. 
    • Under the Galleries heading, select Web Parts.  Your new web part won’t be listed. 
    • Click New at the top and a list of all available assemblies will be displayed. 
    • Click the checkbox next to your new assembly and click the Populate Gallery button to make your web part available to be added to web part zones in your site.

Leave a Reply

You must be logged in to post a comment.