Nick Grattan's Blog

About Microsoft SharePoint, .NET, Natural Language Processing and Machine Learning

Archive for the ‘SharePoint 2010’ Category

Favorite SharePoint Development Tools?

with 4 comments

Here’s a four free development tools you shouldn’t start a SharePoint development project without:

For uploading single or groups of files from the desktop or mail messages from Outlook I use, of course, our “SPDrag&Drop” tool. Take a trial by downloading from here:

Written by Nick Grattan

June 30, 2011 at 1:06 pm

Opening Web Parts Gallery Programmatically

leave a comment »

Navigating to the Web Part Gallery in the browser interface takes you to http://site collection URL/_layouts/_catalogs/wp/Forms/AllItems.aspx. Attempting to open the list through “_catalogs/wp” will fail:

SPList spWPG = spWeb.Lists["_catalogs/wp"];  // does not work

 Instead, you need to use the following code:

SPList spWPG = spWeb.Lists["Web Part Gallery"];


Written by Nick Grattan

June 23, 2011 at 12:21 pm

SharePoint Global Resource (resx) file locations

with 2 comments

Global resource (resx) files are stored in the following locations in SharePoint 2010:

  • App_GlobalResources folder in the VirtualDirectories folder in inetpub (e.g. C:\inetpub\wwwroot\wss\VirtualDirectories\80)
  • Resources folder in the 14 hive (e.g. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Resources)
  • Config/Resources folder in the 14 hive (e.g. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\Resources)

In general, a single resx file in your solution should be copied into each of these locations during installation.  This is how they are used:

  • Resources files in App_GlobalResources are used when code in an ASPX page refers to a resource, e.g.

<asp:Label ID="lblNumberingTitle" runat="server" Text="<%$Resources:GlobalSiteResources, AutoNameTitle %>" />

  • Resources files in the Resources folder are used when referencing resources using the SharePoint object model, e.g.

btnExport.Text = SPUtility.GetLocalizedString("$Resources:GlobalSiteResources, Tab_Export", "GloablSiteResources", language);

  • Resources files in the Config/Resources are copied into the App_GlobalResources folder whenever a new web application is created. By adding the resx files here you will ensure your application will be able to access its global resource files in new web applications.

Written by Nick Grattan

May 24, 2011 at 12:53 pm

Chart Web Part: Hiding “Data & Appearance” and “Advanced Properties”

with 13 comments

The “Chart Web Part” shipped with SharePoint 2010 does a reasonable job of displaying graphs. However, when added to a web part page, it displays “Data & Appearance” and “Advanced Properties” links which can be annoying:

The links cannot be hidden through the web part configuration user interface. Instead you need to:

  1. Open the ASPX page in Microsoft SharePoint Designer 2010.
  2. Locate the Chart Web Part in Code View.
  3. Edit the ShowToolbar property from “True” to “False”.
  4. Save changes.

Now these links will be hidden. You can use the standard drop down web part menu to access them if you need to without re-enabling them:

Written by Nick Grattan

February 15, 2011 at 7:40 pm

SharePoint: Opening CSV files with Microsoft Excel

with 10 comments

By default, if open a .CSV file in a SharePoint the browser will prompt you to save the file. Ideally, you probably want the file to be opened directly in Microsoft Excel. There are two configuration options that need to be made. The instructions here are for SharePoint 2010 but are similar for SharePoint 2007.

  • Add an entry to DOCICON.XML

This file is located by default at: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\XML. Open the file DOCICON.XML for editing and add the following line in the ByExtension element:

<Mapping Key=”csv” Value=”icxltx.png” OpenControl=””/>

This ensures that the Excel icon is displayed alongside CSV files.

Note: if you want to be prompted to open read-only or for edit remove ‘OpenControl=”” ‘ in the Mapping Key.

  • Change the MIME type associated with the CSV Extension in Internet Information Server (IIS)

To do this:

  1. Run the “Internet Information Services (IIS) Manager” application from the Start/Administrative tools menu.
  2. Select the server in the left-hand pane.
  3. Select “MIME Types” in the list of options in the middle pane.
  4. Then locate the .CSV entry (it should already exist) and change the MIME type to: application/, and click OK.

Once these configuration options are complete perform an IIS Reset.

CSV files should now be opened using Excel by default. You will be prompted that a change in file extension has occurred when using Office 2007. You will need to click Yes in this warning message.

Written by Nick Grattan

January 5, 2011 at 9:11 am

Adobe PDF IFilter Indexing with SharePoint 2010

with 40 comments

This note explains how to enable PDF indexing using the Adobe IFilter version 9.0 in Microsoft SharePoint 2010. This note is adapted from the Adobe note explaining how to configure the 64 bit IFilter for SharePoint 2007 (see: ).

Now add PDF as a file type:

  • Run Central Administration.
  • Click Manage service applications under “Application Management”:

  • Click the Search Service Application link in the list of applications.

  • Click File Types  under “Crawling” in the left navigation area:

  • Click New File Type.
  • Enter pdf for the “File Name Extension” and click OK.

  • Using Regedit on the server, navigate to

\\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\Filters

  •  Right-click the Filters  folder and select New Key. Enter “.pdf” for the key value.
  • Add the following values to this key:

<REG_SZ> Default = <value not set>
<REG_SZ> Extension = pdf
<REG_DWORD> FileTypeBucket = 1
<REG_SZ> MimeTypes = application/pdf

 The key should look like:

  • Navigate to: \\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\ContentIndexCommon\Filters\Extension
  •  Right-click the Filters  folder and select New Key. Enter “.pdf” for the key value.
  • Set the “default” value to {E8978DA6-047F-4E3D-9C78-CDBE46041603}

 The key should look like:

You can now add an image to be used for the icon for PDF documents:

  • Add an image (typically gif or png, use Google images to find an example) for the PDF icon to the folder:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES

  •  Open the file docicon.xml from the location:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML

  •  Add a link to map the pdf extension to the image by adding a link like the following to the ByExtension element:

                 <Mapping Key=”pdf” Value=”pdf_icon.gif” OpenControl=””/>

  •  Finally, issue an IISReset and restart the Windows services “SharePoint Foundation Search V4” and “SharePoint Server Search 1”.

Your PDF documents should now be indexed on the next indexing crawl.

 Update 15-Feb-2011: See this blog post for a useful PowerShell script that automates this process:

Written by Nick Grattan

June 14, 2010 at 3:31 pm

Credentials, SharePoint Client Object Model and Silverlight

with 4 comments

When using the SharePoint Client Object Model in Silverlight, you need to add references to the Client Object Model assemblies prepared for Silverlight:

These assemblies are located in the “14” hive: \14\TEMPLATE\LAYOUTS\ClientBin. Note that when using the Client Object Model in other application types you use the libraries located in the ISAPI folder in the “14” hive (Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll).

Before executing Client Object Model calls you need to get a ClientContext object through which calls can be made. When running in a Silverlight application you can do this so:

            ClientContext clientContext = ClientContext.Current;

However, “ClientContext.Current” is only initialized when the Silverlight application is running on a page in a SharePoint site. If you run the Silverlight application on a page in another web site “ClientContext.Current” returns NULL. Creating your own ClientContext object is described in this post – the ClientContext class has a “Credentials” property which can be set through creating a new “NetworkCredentials” object.

But here’s the rub – the Silverlight Client Object Model does not support the Credentials property. So it would seem that Silverlight applications using the Client Object Model can only run in SharePoint sites.

So what about adding references to Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll instead? Doing this causes an error stating that the assemblies have not been prepared for the Silverlight environment.

Written by Nick Grattan

May 20, 2010 at 8:01 am