If you would like to discuss anything, please contact me via email: Howard.Bayliss@sequence.co.uk

Friday, October 28, 2011

SharePoint Anonymous Access

I was trying to change the Anonymous Access settings for a list, as per this screen:

SharePoint Anonymous Access checkboxes

However, when I checked the "Add Items" box and clicked OK, it did not save the changes. Everytime I repeated this and went back to the screen, the "Add Items" box was not checked.

The cause of the problem was that the Anonymous Policy for the SharePoint Application (that hosted the site) had been changed. By default this is set to "None". However, it had been set to "Deny Write".

SharePoint Anonymous Policy

There wasn't a good reason for this and switching it back to "None" fixed the problem.

Thursday, October 27, 2011

DataFormWebPart maximum field lengths

I used a DataFormWebPart to generate a custom edit form. Our client wanted to limit the maximum length of various fields on this form, but didn't want these to be applied site-wide.

The built-in SharePoint fields (FormField, TextField, NoteField, etc) don't have a "maxlength" property.

The solution was to modify the template for the various fields within the DataFormWebPart XSLT, to include RegularExpressionValidators.

Credit to Bart McDonough for this. His blog post relates to creating a new field type, but I tried it within the DataFormWebPart and it worked.

The nice thing about this is that the validation will take place on both the client and the server

Here is a sample from my DataFormWebPart XSLT file. This sets the maximum length of a text field to 80 characters.

Note that the curly braces in the regular expression have to be escaped. If you don't do this, the XSLT will break.

<SharePoint:TextField runat="server" id="ff1{$Pos}" ControlMode="Edit" FieldName="Title" __designer:bind="{ddwrt:DataBind('u',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}">


<asp:TextBox id="TextField" runat="server"/>
Text="Value cannot exceed 80 characters."
runat="server" />



Wednesday, October 26, 2011

SharePoint Check "page layout"

In code, I had a reference to an SPFile object and I wanted to check if the SPFile was a page layout file.

I used code (similar to the sample below) to do this. It checks to see if the file's parent list is the master page / page layout library.

Maybe you know a better way?

string url = " -- ABSOLUTE PATH TO YOUR FILE -- ";

using (SPSite site = new SPSite(url))
using (SPWeb web = site.OpenWeb())
SPList masterPagelist = site.GetCatalog(SPListTemplateType.MasterPageCatalog);
SPFile file = web.GetFile(url);

if (file.Item.ParentList.ID == masterPagelist.ID)
// The file is in the master page library.

Monday, October 24, 2011

SharePoint SummaryLinks "Edit Properties"

While logged-in as a user with Contributor permissions, I noticed that the toolbar for a Summary Links field was not visible on the Edit Form of a publishing page.

This is is shown in the picture below:

SummaryLinks has no

I suspect this is a SharePoint bug as the toolbar was visible when the page was in WYSIWYG edit mode.

Also, the issue did not occur when logged-in as a Site Collection administrator.

A work-around to this issue is to give the user the Manage Lists permission. However, this is really not something you should consider lightly as it gives editors an awful lot of power.

I'm going to speak to Microsoft to see what they say about it and then I'll post an update....


Microsoft has acknowledged that this is an "Offbug" (as they call it). In other words, it's a bug in their code.

This will be fixed in a future hotfix or service pack. However, they will not / cannot give a date for the fix.