Tuesday, June 9, 2009

SQL Server Autogrowth for SharePoint

I was aksed today what Autogrowth setting would be best for a SharePoint Content Database. The simple answer? None! Autogrowth is one of the biggest resource eaters on badly designed SharePoint SQL Farms and can cause serious performance and stability issues (plus wreck havoc with your Hard Disks). The best option is to start big enough for your initial load and plan growth ahead.

Example: You are starting a new SharePoint ECM project and are planning on migrating 5 GB worth of files into the SharePoint Sites at go live. You also realise that you have never used versioning before and your staff will be quite active on about 10% of those files. Expecting to create on average one new version every week. i.e 500MB worth of new data being added every week. Thus scheduling a db file growth of 500MB during every weekend would deal with versioning. Add 100MB for new content to total it up to 600MB for week 1, 610 for week 2, 620 for week 3 and so forth, taking into account the growth of the files and the increase on versioning.

Having a sound versioning strategy with a cap for Major and Minor versions will help reign in this excessive growth!!!!

Obviously you will not always get it right and thus a combination of large Autogrowth (for example in 100MB increments) and weekly scheduled growth will give you the best combination for maximum performance and stability.

The final statement? Try to minimise the amount of times the dbs autogrow as much as you can by planning ahead, and when they do auto grow mak sure the increments are large enough to keep you going withminimal disruption until the next scheduled growth. Don't make them too large either as fetching hard disk space for the db files can put a strain on the Disks at the most impractical times like during peak hours and impair the stability of the system

Theme not updating on refresh

If any of you have been working with themes in your visual studio projects you probably didn't get them right frst time. Heck, you probably didn't get them right after the 50th update. If you're creating the theme in a wsp and keep on deploying it and are only working on one single site with no sub sites, then you won't have the update issue. But my guess is that you do.

As soon as you apply a theme to a site it copies the theme.css into the site under the _themes folder. This means the page is automatically unghosted and any changes simply won't show up unless you remove the theme and reapply the theme. The solution to the dilemma is to put all the real css stuff into a separate css file somewhere in the hive (preferrably under layouts/styles or layouts/1033/styles) and only reference it from the theme.css using the import statement.

Sure it is a bit hacky, and yes, you would also put all the images into a folder outside of the actual theme folder but hey! a) it works, b) you can see your changes reflected instantly across all sites using the theme and c) it still can be packaged into a feature and wsp package meaning you'll be fine even after the next update.

Heather Solomon, the master of sharepoint css has a great article on how to do the referencing with themes on her blog:


Friday, June 5, 2009

updating a layout using features

It is well known now that probably the best way to use site definitions and features is to start off with the most basic definition and do as much as possible in the feature. That also includes things like page layouts and master pages.
Words of warning. Ghosting and Unghosting can trick you into thinking that the updates are not working. As soon as you decide to customise a page using SPD which was deployed via a feature, SharePoint will put a copy into the database and always load that one instead of the ghosted one on the file system. Thus you can update your feature as often as you like, you won't see the changes. Solution?
make sure you have all modificaitons in the source file and reset the layout page to Site definition. Strictly speaking it never was part of a "site definition" but part of a feature, so you won't find the Reset button in SPD, but you can still reset it manually using the web interface. Simply copy the url of the page in question, go to Site Settings and there you will find a link to Reset to Site Definition where you can past the link.

Something Else I noticed though. If you customise the layout page to include web parts on creation using the AllUsersWebPart tag, like the Table of Contents Webpart in Andrew Connel's Minimal Site Definition example, each time you reinstall the feature a new instance of the web part will be added to the layout definition, causing multiple instances to be created on the new page creation. So try to stay away from web part customisation in layouts if you can.

Finally, you might want to make other property changes, like providing a new Preview image url or modifying the content type or such. These settings live on the list item and not in the file. Editing the item will solve those problems but as soon as you check your changes in, the page will be unghosted and you're back at the first dilemma. No worries though. Simply reset to site definition again and you're as good as gold. Yup, the changes to the list item don't go lost when doing that reset, so you won't lose those updates.


Bye Bye Groove, Hello SharePoint Workspaces

In the past many people have asked me what this Groove thing is about. Looks like a miniature version of SharePoint I was told by some. Others called it the Briefcase on Steroids. Most people who were implementing SharePoint though called it surperflous. And they had a point!
With a good Information Architecture and Enterprise Content Management Strategy babsed on SharePoint a tool such as Groove should not be required. Especially as it was not SharePoint compatible and mimicking a file sharing application more than a collaboration tool.
I'm not saying that Groove was a bad idea. Having a desktop tool which makes working on shared documents easier and more intuitive without the need to use a web interface for access is a great idea. That's why making Groove SharePoint savvy and making it more like a SharePoint Workspace tool makes even more sense.

Still in its infant stages, but there is now a new blog for the new project
A good place to keep tabs on to see what kind of SharePoint Integration is coming in the next version of Office and how the bridge between SharePoint ECM and productivity applications is becoming stronger and more seamless.

Wednesday, June 3, 2009

Integrating AJAX Control Toolkit into SharePoint

Hey folks, sorry it took me a week to get round to this blog post, but I needed to make sure I could upload all the stuff somehow. This is going to be a big one, so sit back, relax and enjoy the show:

Ajax Control Toolkit

A compilation of dynamic controls
—With and without Server Side interaction
—Built on the System.Web.Extensions Components
—Samples at http://www.asp.net/ajax/
—Source at http://www.codeplex.com/


—ASP.NET 2.0 AJAX Extensions v1.0
—Ajax Control Toolkit 20229 (.net 2.0)
—Windows SharePoint Services 3.0 SP1
—NET Framework 3.5 SP1
—Ajax Control Toolkit 30512 (.net 3.5sp1)
—Windows SharePoint Services 3.0 SP2

How to get it running? a combination of tweaking the web.config, and clever web part design

Configure the web.config

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />

Allow Ajax controls on the pages

<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

Add Extensions Assembly

<add assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

Add Ajax Http handlers

<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>

Add Http Module

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

Add WebServer config section (IIS7.0 only)

<validation validateIntegratedModeConfiguration="false"/>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<remove name="WebServiceHandlerFactory-Integrated" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode“
System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

Optional, add profile config

<authenticationService enabled="true" requireSSL = "truefalse"/>
<profileService enabled="true” readAccessProperties=“First,Last"
writeAccessProperties=“First,Last" />
<scriptResourceHandler enableCompression="true" enableCaching="true" />

IMPORTANT: Mark Ajax controls as Safe

<SafeControl Assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TypeName="*" Safe="True" />

Add Script Manager to Page

To the master page right at the top
<asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>
Or programatically in a baseclass for your AJAX enabled Webparts
protected override void OnInit(EventArgs e)
if (ScriptManager.GetCurrent(this.Page) == null)
ScriptManager scmanager = new ScriptManager();
scmanager.ID = "scriptManager";

Next up: a sample WebPart that uses the AutoComplete control from the toolbox . Before you can use the toolkit you will need to download and compile the project though. Then add the reference to the toolkit in your WebPart Project.

using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using AjaxControlToolkit;

namespace KnowledgeCue.WSS.AjaxWebParts
public class AutoCompleteTextBox : KnowledgeCue.WSS.BaseWebPart
Literal textBoxLabel = new Literal();
TextBox textBox = new TextBox();
AutoCompleteExtender autoComplete = new AutoCompleteExtender();

public AutoCompleteTextBox()

protected override void CreateChildControls()
string webServicePath = "http://wss-1:90/_layouts/AutoCompleteService.asmx";

textBoxLabel.Text = "Type the name of a cool dude";
textBox.Attributes.Add("id", "SelectCoolDudeTextBox");
textBox.ID = "SelectCoolDudeTextBox";
this.Controls.Add(textBox); ;

autoComplete.MinimumPrefixLength = 1;
autoComplete.ServicePath = webServicePath;
autoComplete.ServiceMethod = "GetCoolDudes";
autoComplete.TargetControlID = "SelectCoolDudeTextBox";
//Script Manager Fix
protected override void OnInit(EventArgs e)
if (ScriptManager.GetCurrent(this.Page) == null)
ScriptManager child = new ScriptManager();
child.ID = "scriptManager";
if (this.Page.IsPostBack)
this.Page.ClientScript.RegisterStartupScript(typeof(AutoCompleteTextBox), this.ID, "_spOriginalFormAction = document.forms[0].action; _spSuppressFormOnSubmitWrapper=true;", true);
if (this.Page.Form != null)
string str = this.Page.Form.Attributes["onsubmit"];
if (!(string.IsNullOrEmpty(str) !(str == "return _spFormOnSubmitWrapper();")))
this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
this.Page.Form.Controls.AddAt(0, child);

Finally, the Webservice which the autocomplete textbox relies upon:
<%@ WebService Language="C#" Class="AutoCompleteService" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class AutoCompleteService : System.Web.Services.WebService {

public System.Collections.Generic.List<string> GetCoolDudes(string prefixText, int count) {
string[] dudes= new string[] { "Alex Dean", "Chandima Kulathilake", "Rachael Greene", "Dean Moor", "Duncan Hammond" };
System.Collections.Generic.List<string> dudeList = new System.Collections.Generic.List<string>();
int i = 0;
foreach (string dude in dudes)
if (i == count) break;
if (dude.ToLower().StartsWith(prefixText.ToLower()))
return dudeList;


SPVisualDev File exists in Template Error

I've stumbled across this one and it took me some time to figure it out. That error will crop up if you are deploying a file either via a feature or site template twice. In my case I had two Modules in an elements file to split up the Preview images from the actual files being deployed to the masterpage gallery. that's where SpVisualDev gets its knickers in the twist. Can't deal with multiple modules in one file and keeps on adding all files to the last module. also the ones that are already referenced in the first one.
Fix? put all files into one module or SPVisualDev will screw with the elements and it won't work.

Basic Publishing Site Definition

Andrew Connell wrote in his great SharePoint 2007 WCM book how to create a Minimal Site Definition to use for Publishing Sites. The idea is to have a clean starting point for new Projects which use Features as the main tool for customisation. The Site Definition itself is pretty basic and stripped down to its bare necessities while all the fun stuff lives in Features. A great way to start a project is to plan ahead what functionality will be living in different features, adding basic shell like features to the definition at the start and actually do the coding later. But even if you didn't plan for everything in advance and realise that there is a feature missing or a piece of code that can't be integrated into an existing feature, simple staple it on top of the Site Definition in hind sight and you're as good as gold.
Wrox Press also give you the code for that Book for download on their website. The Solution for the Minimal Site Definition you'll be lookng for lives in Chapter 5. But beware, there are a few bugs in the download. Check the Errata for Errors in Download and fix up the onet.xml and publishing layout page.
One thing that was missed totallly in this definition is the fact that all pages should live in the Pages Library. Also the homepage. In the example from Andrew, the home page lives WSS style in the Root. Not very clean. The fix is simple enough though: Change the url of the page (preferably even changing the default.aspx to actually use the layout properly!) and you're ready to go. Here is my version of the last entry in the onet.xml file:

<Module Name="Default" Url="" Path="">
<File Url="default.aspx" NavBarHome="True" Type="Ghostable" />


<Module Name="Default" Url="$Resources:cmscore,List_Pages_UrlName;" Path="">
<File Url="Default.aspx" Type="GhostableInLibrary">
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/PSATOC.aspx, ~SiteCollection/_catalogs/masterpage/PSATOC.aspx" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_welcomepage_name;" />