Friday, 31 August 2012

PowerShell - Event Receivers on SharePoint List

There are times when you want to check which event receivers are attached to a SharePoint list.   This can be easily achieved through use of a PowerShell script.

$spWeb = Get-SPWeb Identity http://sharepoint
$spList = $spWeb.Lists["My List"]  
$spList.EventReceivers | Select Name, Assembly, Type

There are also times when you might want to remove any event receivers from the list

$spWeb = Get-SPWeb Identity http://sharepoint
$spList = $spWeb.Lists["My List"]  
$spList.EventReceivers | Select Name, Assembly, Type

$eventsCount = $spList.EventReceivers.Count

for ($i = $eventsCount-1; $i -ge 0; $i--)


Wednesday, 29 August 2012

SharePoint - REST : Feed Format not supported

With REST services looking like they are going to be playing a bigger part of the next version of SharePoint I felt it was time long over due for me to take a look.

I started with a basic query to return an item from a list based on its ID:

  • http://sharepoint/_vti_bin/listdata.svc/MyCustomList(1)

However,  when entered into IE I was presented with the following message:

Internet Explorer cannot display this feed

Internet Explorer does not support this feed format

Quite a simple fix:

Within IE click Tools –> Internet Options –> Content

Within the the Content Tab click on Settings button within the Feeds and Web Slices section:


Within the Feed and Web Slice Settings window uncheck the “Turn on feed reading view” then Click OK.


Now when I execute the query I get my results:


First hurdle overcome lots more to learn!!!

Monday, 27 August 2012

.NET Select Distinct Values From DataTable

To select distinct values from a DataTable you can make use of the DataView:

DataView view = new DataView(dt);
DataTable distinct = view.ToTable(true, "columnname");

Tuesday, 21 August 2012

SharePoint 2010 - asp:CreateUserWizard

While using the asp:CreateUserWizard control to add forms based authentication users to my asp membership database I was encountering the following error:

Exception of type 'System.ArgumentException' was thrown.
Parameter name: encodedValue

The error above was being generated after I successfully created a new user.  The issue it seems is with the control creating a cookie named:  .ASPXAUTH

The solution expire the cookie.

private void ResetAuth()
  HttpCookie aspCookie = new HttpCookie(".ASPXAUTH");
  aspCookie.Expires = DateTime.Now.AddDays(-1);

This needs to be done on both the ContinueButtonClick and the onActiveStepChanged Event.


protected void ActiveStepChanged(object sender, EventArgs e)


protected void btnContinue_Clicked(object sender, EventArgs e)

A more detailed explanation of this and other login control issues can be found here within Bernado Nguyen-Hoan's Blog