SharePoint 2007 – No parameterless constructor defined for this object
I needed to edit a page layout in a Publishing Site and I was adding a custom web part using SharePoint Designer. Everything seemed to be working fine (the...
SharePoint 2007 Debugging – Show Error Messages
Sometimes debugging SharePoint errors is not the easiest of tasks. The most common and annoying situation is when the "An unexpected error has occurred" error message is shown and...
SharePoint 2007 Deployment Tools
I recently found in the CodePlex web site, two very interesting and useful tools to ease the process of deployment of a SharePoint 2007 solutions:
SharePoint Solution Installer – You...
SharePoint 2007 – Restore Closed Web Parts
In SharePoint 2007 web sites, web parts can be removed from a web part page using two methods:
Closing the web part (by clicking the "X" button)
Deleting the...
Custom Action for Sharepoint Designer
I'm going to create a custom action for Sharepoint Designer that creates a discussion thread in a discussion list based on the current list item.
I'm going to use the...
How to upload a list template
public static SPFile UploadListTemplate(string siteUrl, string templatePath)
{
using (SPSite site = new SPSite(siteUrl))
{
SPDocumentLibrary templates = (SPDocumentLibrary)site.GetCatalog(SPListTemplateType.
ListTemplateCatalog);
System.IO.FileInfo fileInfo = new System.IO.FileInfo(templatePath);
byte bytes = System.IO.File.ReadAllBytes(fileInfo.FullName);
return templates.RootFolder.Files.Add(fileInfo.Name, bytes);
}
}
How to upload a site template
public static SPFile UploadWebTemplate(string siteUrl, string templatePath)
{
using (SPSite site = new SPSite(siteUrl))
{
SPDocumentLibrary templates = (SPDocumentLibrary)site.GetCatalog(SPListTemplateType.WebTemplateCatalog);
System.IO.FileInfo fileInfo = new System.IO.FileInfo(templatePath);
byte bytes = System.IO.File.ReadAllBytes(fileInfo.FullName);
return templates.RootFolder.Files.Add(fileInfo.Name, bytes);
}
}
How to create an item in a discussion list
Creating a discussion in discussion list is different from creating a simple list item. The code for creating a discussion item is:
using (SPSite site = new SPSite("SITE URL"))
{
...
Built-In ContentType and Field Ids
Only today that I've found that the WSS object model has 2 classes that hold all the IDs of the built-in ContentTypes and Fields.
Instead of doing things like this:
SPListItem...
ItemUpdating, AfterProperties and field names
I was checking for a field value change in a WSS V3 list with the help of event handlers with no success.
In the ItemUpdating event, the list item has...