Problem: You have developed a custom web part and under some conditions you want to hide it from view. A couple of solutions spring to mind; In your CreateChildControls() method you determine that you need to hide the webpart and simply create no controls, effectively returning before any controls are created. At some approriate point in the [...]
Read more
SharePoint 2007: Using the ListFormWebPart on a Publishing Page
I was attempting to re-use a ListFormWebPart in a custom webpart which would be placed on a publishing page, in this case the webpart would display the metadata properties for document library items using custom rendering templates, with the parameters for the List and Item Id’s being supplied by page querystring parameters. The initial code [...]
Read moreUsing the SharePoint Object Model in WebPart Constructor Causes Security Exception
Writing a web part recently, I was attempting to set some default values for locale sensitive properties. I wanted them set early in the webpart lifecycle so I figured I’d do it in the web part constructor. Since they are locale sensitive I was using the SPUtility.GeLocalizedString method to fetch the value from resources. When [...]
Read moreSharePoint: Content Query Web Part Customizing the Query
Recently I’ve been customizing Content Query Web Parts (CQWP) whereby I override the query and supply my own CAML query. The basic steps involved in doing this are; Author the Web Part using the UI Export the Web Part using the UI Customize the Web Part .webpart file Import the customized Web Part back into [...]
Read moreProvision a WebPart using a SharePoint Feature.
Moving on from this post, you’ve developed a custom WebPart and you want to package it up for deployment to SharePoint (and you’re not using VSeWSS or WSPBuilder for some reason), or, you’ve customized an OOTB WebPart and want to package it up for reuse in a feature. Starting with your webpart description file, which [...]
Read more

March 2, 2012

