SharePoint: Detect Page Edit or Design Mode in Publishing and Non-Publishing Sites


In your web part or user control, you may wish to know if the page on which your asset is placed is in edit or design mode, in order to alter the behaviour in some way. How you do this depends on whether you’re using a publishing or non-publishing site. In a publishing site, you can detect … Continue reading SharePoint: Detect Page Edit or Design Mode in Publishing and Non-Publishing Sites

SharePoint: Adding Custom Web Part to Page Layout causes No Parameterless Constructor Exception


After adding a custom web part to a publishing page layout using SharePoint Designer, I tried creating a page instance using the page layout and was presented with the following exception; Exception type: MissingMethodException Exception message: No parameterless constructor defined for this object. at System.RuntimeTypeHandle.CreateInstance(…)    at System.RuntimeType.CreateInstanceSlow(…)    at System.RuntimeType.CreateInstanceImpl(…)    at System.Activator.CreateInstance(…)    … Continue reading SharePoint: Adding Custom Web Part to Page Layout causes No Parameterless Constructor Exception

SharePoint: Adding Default Web Parts to a Publishing Page Layout with Feature Provisioning


You want to add a set of web parts to your publishing page layout, so that when users create new instances of a page using your layout, the page is created with some web parts already added to the page for them. You may want the web parts in that web part zone to be … Continue reading SharePoint: Adding Default Web Parts to a Publishing Page Layout with Feature Provisioning

SharePoint: Programmatically Hiding a WebPart and Web Part Zone Spacers


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 … Continue reading SharePoint: Programmatically Hiding a WebPart and Web Part Zone Spacers

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 … Continue reading SharePoint 2007: Using the ListFormWebPart on a Publishing Page

Using 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 … Continue reading Using the SharePoint Object Model in WebPart Constructor Causes Security Exception