July 24, 2007 - 11:52, by Steven Van de Craen
Categories: SharePoint 2007
By default your SharePoint pages are ghosted, which means the layout template is stored on the web front end server's file system, while the content is stored in SQL Server.
Once you make modifications to a page using SharePoint Designer 2007, the page becomes unghosted; both layout and content are stored in SQL Server and the file is detached from the template page.
There are some concerns with this:
- Performance: allthough ASP.NET 2.0 is said to solve this, it still remains a fact that the page is stored entirely in SQL Server.
- Design implications: once the page is detached from the template, changes to that template won't be reflected on the unghosted page. Any future updates must be done using SharePoint Designer. Using SharePoint 2007 this is not very catastrophic since the master page defines the design and the content page only contains a reference to it's master page.
Now there's also Site Templates and Site Definitions. The former are created by just a few clicks on a button (Save site as template...) while the latter includes more flexibility and scalability but also more development time.
Q. How does a Site Template really behave when it comes to ghosting/unghosting ?
Let's say you create a new Team Site, add Web Parts, SharePoint Lists and Libraries, theme it, etc. Next you save this site as a .stp (Site Template) to create other sites with it, are these sites ghosted or unghosted ?
A. It depends.
A .stp file is really a zip archive containing a manifest.xml and unghosted pages.
The manifest contains a reference the original Site Definition (e.g. a standard 'Team Site') and a delta of the changes to the original definition. Any changes to lists or libraries, web parts or site settings will be included in the manifest.
This also means that the original Site Definition must be available on the (each) web front end server for the Site Template to work.
If you modified any pages using SharePoint Designer 2007 (causing them to be unghosted), they will be added as separate files in the .stp file.
Conclusion
A Site Template is in general fully ghosted except for unghosted pages that are already present.
Applies To
WSS 3.0
July 24, 2007 - 11:46, by Steven Van de Craen
Categories: SharePoint 2007
Issue
This had me troubling for quite a while and looking on the Internet didn't really give any real solutions (here and here).
In my case the errors were caused by a custom Web Service that I added to SharePoint. When one of the Web Parts called the Web Service an event log entry was written:
Event Type: Error
Event Source: Office SharePoint Server
Event Category: Publishing Cache
Event ID: 5785
Date: 29/01/2007
Time: 11:58:36
User: N/A
Computer: VPC-WS03
Description:
Unable to connect publishing custom string handler for output caching. IIS Instance Id is '238027762', Url is 'http://localhost/_myws/Service1.asmx'.
Solution
The solution is to modify the web.config of the Web Service application. Remove the PublishingHttpModule module that was added by the root web.config:
...
Applies To
MOSS 2007 (because the problem relates to Publishing)
July 24, 2007 - 11:43, by Steven Van de Craen
Categories: SharePoint 2003, SharePoint 2007
General
When creating sites through the SharePoint Object Model, the Web Services or the Web Interface you need to filter the illegal characters when specifying the Site Name (which is the part of the URL that references your site).
Here's a list of common illegal characters: # % & * { } \ : < > ? / +
In addition to this list it is prohibited to have consecutive periods in the URL. It's also prohibited to start or end with a space or underline, or to end with a period.
I've found out by experience that non-consecutive periods in Site Names are allowed, but then MOSS 2007 Search doesn't show these sites in its results, so it's best to have no period at all in your Site Name.
Finally there's the comma. It's not on the illegal character list, but be cautious when allowing it. If you add a link to that site through the SharePoint Object Model you might run into problems because the URL Field stores both URL and Description separated by ', ' (a comma followed by a space). The code will think your comma is part of the separator. This in turn can be solved using an UrlEncode but this is easily overlooked.
Code Sample
// Use SPUrlUtility for removal of illegal characters: # % & * { } \ : < > ? /
int illegalCharIndex = SPUrlUtility.IndexOfIllegalCharInUrlLeafName(newSiteName);
while (illegalCharIndex > -1)
{
newSiteName = newSiteName.Remove(illegalCharIndex, 1);
illegalCharIndex = SPUrlUtility.IndexOfIllegalCharInUrlLeafName(newSiteName);
}
// Extra removal of illegal characters ignored by SPUrlUtility: + . ,
newSiteName = newSiteName.Replace("+", "");
newSiteName = newSiteName.Replace(".", "");
newSiteName = newSiteName.Replace(",", "");
// Removal of leading/trailing spaces and underscores
newSiteName = newSiteName.Trim(' ', '_');
You could of course avoid SPUrlUtility and manually strip all illegal characters, which might be less trouble alltogether.
Applies To
WSS 2.0, WSS 3.0
July 24, 2007 - 11:38, by Steven Van de Craen
Categories: General
I'm currently programming some connectable Web Parts for MOSS 2007 and want to make this a small note to self:
Web Part Life Cycle on page load
- OnInit
- OnLoad
- Connection Consuming
- CreateChildControls
- OnPreRender
- Render (RenderContents, etc)
Web Part Life Cycle on button click
- OnInit
- CreateChildControls
- OnLoad
- Click Event Handling
- Connection Consuming
- OnPreRender
- RenderContents
Keep this in mind because if you set a variable in the 'Connection Consuming' step, you can only access it after the step has occurred. So if you want to use it before that step you must store it in ViewState/Cache/other.
July 24, 2007 - 11:36, by Steven Van de Craen
Categories: Office 2007
July 24, 2007 - 11:25, by Steven Van de Craen
Categories: General, SharePoint 2007
Make sure the SQL Server collation for your SharePoint 2007 databases is set to Latin1_General_CI_AS_KS_WS.
- Case insensitive
- Accent sensitive
- Kana sensitive
- Width sensitive
This was implemented because this collation most resembles NTFS file name restrictions.
July 24, 2007 - 11:16, by Steven Van de Craen
Categories: General, SharePoint 2007
My first article on MSDN Belux:
http://www.microsoft.com/belux/msdn/nl/community/columns/stevenvandecraen/contentquerywebpart.mspx
It was written for MOSS 2007 Beta 2 but still very much applies to MOSS 2007 RTM.
July 24, 2007 - 11:08, by Steven Van de Craen
Categories: SharePoint 2007
Description
A SharePoint Library event handler to automatically link a picture to a MOSS 2007 User Profile.
The file names must be of the following format: [accountName].[ext]
ItemAdded
- The event handler extracts the account name from the new file
- The Profile Picture URL property of the corresponding User Profile is updated
- In case of an error an entry will be written to the machine's event log
ItemUpdating
- The event handler does not allow a file to be renamed
ItemDeleting
- The event handler resets the Profile Picture URL property of the correspondingg User Profile
- In case of an error no additional actions are undertaken (just the file deletion)
Screenshot
Requirements
This event handler uses User Profiles and thus requires MOSS 2007.
Downloads
Visual Studio 2005 Project + compiled assembly
Instructions
Installation:
Register this event handler for a SharePoint Library (Document Library, Picture Library, ...) or Content type using the SharePoint Object Model, my EventHandlerManager or any other tool.
Feel free to modify and improve this project.
Additional notes
The original version of this Event Handler included additional checks in the ItemAdding event returning an informational message to the user. However my experience of synchronous event handling (and UI messages) in combination with a Picture Library haven't been very good: WSS 3.0 Event Handler- pre-event cancelling issues, so I have omitted that functionality.
July 24, 2007 - 10:40, by Steven Van de Craen
Categories: SharePoint 2007
Description
A tool for registering/unregistering Event Handlers from a SharePoint List or Library. It uses an XML file to register event handlers.
http://localhost/hr/employeepictures" contenttype="" eventtype="ItemAdded" />
http://localhost/hr/employeepictures" contenttype="" eventtype="ItemUpdating" />
http://localhost/hr/employeepictures" contenttype="" eventtype="ItemDeleting" />
- The definition root node can contain multiple definition nodes
- A definition node has attributes assembly and class pointing to the event handler location
- A definition node can contain multiple list nodes
- A list node has attributes
-
url: the absolute URL to the SharePoint List or Library
-
contenttype: the name of the content type to which the event handler registers to. if empty the event handler is registered to the list
-
eventtype: one of the SPEventReceiverType enumeration values
Screenshot
Requirements
This tool requires WSS 3.0.
The tool must be run locally on the SharePoint server.
Downloads
Visual Studio 2005 Project + compiled executable
Instructions
Run the tool and specify the path to the XML file that will be used. You can view the XML file contents using the "View" button.
Use "Register" or "Unregister" to process the XML file. A log file will be generated for each Event Handler definition. After processing the XML file the log file will open for display.
If a definition fails the log file will show the error message. An entry will also be written to the machine's event log.
July 23, 2007 - 12:28, by Steven Van de Craen
Categories: SharePoint 2007
A while ago I blogged about creating a custom site definition for WSS 3.0/MOSS 2007. The problem I experienced today was with a WSS 3.0 installation and creating sites programmatically.
Say I have copied the STS Site Definition and made some changes so only the 'blank' template remains. I add the webtempstsvandest.xml file to the correct location and restart IIS.
Next I create a new site with the Site Definition and save it as a template MyCustomSite.stp.
When I call the SPWebCollections.Add(url, title, desc, 1033, "MyCustomSite.stp", false, false); only to receive the following exception:
File or arguments not valid for site template
The problem in my case was in the webtempstsvandest.xml file which looked like this:
The culprit is the AllowGlobalFeatureAssociations attribute that is set to false. This should only be the case for the Blank Site site template and the Shared Services Provider site template.
Note:
Creating a site using the GUI does not give the above exception but creating a new Document Library on that site will likely fail.
References:
- http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spwebtemplate.allowglobalfeatureassociations.aspx
- http://www.kbalertz.com/kbNamed_936908/936908.aspx
Next >>