SharePoint REST Service ListData.svc and JQuery

This is a sample code on JQuery how you can retrieve a value from a SP 2010 REST service and display it in a HTML element.

In this case this is a piece of code that was used with a blog post xsl output.

There are 3 parts in this code:

1.  Find out the relative URL of the site in the current SP site

var location = window.location.pathname;
location = location.replace(“Lists/Posts/Post.aspx”, “”);

2.  Make a ajax call to the “ListData.svc” service. In this example “Posts” is the name of the posts library in a Blog site. The GetQueryStringParams is a JS function that retrieves the post (list item) ID to be passed to the service and the “LikesCounter” is the field which value we want to get.
type: “GET”,
url: location + “/_vti_bin/ListData.svc/Posts(” + GetQueryStringParams(“ID”) + “)/LikesCounter”,
dataType: “xml”,
success: parseXmlLikesCounter

URL Samle for the AJAX call:


3. Take the value from the service. Strip it of any additional XML elements and get the value. In this case the single value is going to contain some extra XML defining the type of the data etc. I did not need that so I stripped any extra info and kept only the data from the field.
function parseXmlLikesCounter(xml) {
$j(xml).find(“Counter”).each(function () {


XML Samle of the response from the service:

<?xml version=”1.0″ encoding=”utf-8″ standalone=”yes” ?>
<LikesCounter p1:type=”Edm.Double” xmlns:p1=”; xmlns=””>1</LikesCounter&gt;

More info on the REST service in SharePoint:

ASP .NET WebPart, Control Or Page loads twice problem

Another issue hit me today and spent some time debugging it. As the title says my control events all launched twice. This caused problems to my code logic and also it is an unnecessary performance hit to do something twice when one rendering pass is what is enough.

The problem was due to the <asp:image control inside my SharePoint 2010 Visual Webpart. For some reason(I’m gonna say a bug in MS code, it seems like it) if you did not set the image URL of the control while it is created OR defined(lets say on the ASCX side my webpart) you will suffer from double loading.

Of course this did not solve my problem entirely until I decided to ditch the <asp:image control and replace it with a HTML server side control <img. NOTICE that I still had to set the img src attribute to some location while defining the control.

Example of the control definition:

<img src=”#” id=”iBlogImage” runat = “server”/>

.NET and SharePoint HttpModules

Today I ran into a problem where my HttpModule was not working. No matter what I did I could not access my code under Visual Studio debugger. In other words my breakpoints did not work.

After a long time of wondering and some Googling I found out that the problem was related to how my HttpModule was being registered to the web application.

In my case I was working on a SharePoint 2010 project and was adding the module registration through a feature.

To put it simple if you are using IIS7 you need to register it under the “modules” element in the web.config file. If you are using lets say IIS6 then you need to register the module under the httpmodules element of  the web.config file.

Example under IIS7:

return new SPWebConfigModification(“add[@name=’My.HttpModule’]”, “configuration/system.web/modules”)
Value = @”<add name=””My.HttpModule”” type=””myassembly namespace info etc”” />”,
Owner = properties.Feature.DefinitionId.ToString(),
Sequence = 0,
Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode

Resources: SharePoint MySites, User Profiles, AD/Users and Alerts

Here are some links to resources that I have used in my years with SharePoint developing and fixing SP solutions. Hope this helps someone.


Customizing MOSS 2007 My Sites within the enterprise

Customising the “My Site” Templates – Point2Share – Site Home – MSDN Blogs

Talk Sharepoint Only: MySIte Customization

Customizing MySite in MOSS 2007 – Sridhar’s blog – Site Home – MSDN Blogs

Customizing My Sites in Microsoft SharePoint 2010 – Microsoft SharePoint Social Computing Team Blog – Site Home – MSDN Blogs

SharePoint @ Big Scholar » Blog Archive » Customise and Branding MySites

SharePoint MySite Branding

Salman’s Blogs » MySite Branding for SharePoint 2010

Set up My Sites (SharePoint Server 2010)

Configuring My Site in SharePoint 2010 | SharePoint George

User Profiles:

Syncing WSS and MOSS User profile properties with Active Directory « SharePoint Notes

Updating SharePoint 2010 User Information « SharePoint Automation

Account Deletion and SharePoint 2010 User Profile Synchronization

User Profile creation and the impact of AD synchronization/import | dev.notes.share()

Get user Profile in SharePoint 2010 | Enter your blog name here

SharePoint 2007: A user’s presence information does not appear correctly in People search results intermittently

People Search: Use a custom Ranking Model to search in added Profile Properties

SharePoint Steve » Making Custom User Profile Properties Searchable in SharePoint 2010

SharePoint User Profile Custom Properties Keyword Search Problem « kgraeme

SharePoint 2007: All you ever wanted to know about User Profiles – Sahil Malik |

How user profile synchronization works in SharePoint 2010 – Microsoft SharePoint Social Computing Team Blog – Site Home – MSDN Blogs

User Profile Information not updated on site collection’s people and group – Sharepoint made easier – Site Home – TechNet Blogs

Missing “I like it” and Tags on SharePoint 2010 – Jojo Koshy – Site Home – MSDN Blogs

Troubleshooting User Profile Sync Issues in Office SharePoint Server 2007 – My SharePoint World! – Nishant Shah – Site Home – TechNet Blogs


SharePoint Blog – René Hézser – Display all my alerts

How To Create Alerts Programmatically | Sharepointology

Sending alerts to groups in Sharepoint 2007 « Gavin’s Sharepoint Blog

Sharepoint 2007 task notification alert emails not working – Mel Lota’s Weblog

Sharepoint Tips And Tricks: Email Alerts not getting sent, while other emails are

SharePoint Alerts Not Working | SharePoint Geek

How to Troubleshoot Alerts in WSS 3.0 / MOSS – THE OFFICIAL BLOG OF THE SBS “DIVA”

Robin’s Sharepoint Blog: Alerts not working *all the time*

Zeb Sadiq | SharePoint 2010 custom alert template

Customizing Alert Notifications and Alert Templates in Windows SharePoint Services 3.0 – Microsoft SharePoint Developer Documentation Team Blog – Site Home – MSDN Blogs

Creating custom list alert templates in SharePoint 2010

Customizing Alert Templates in SharePoint Foundation 2010 – Developer –

How To: Customizing alert emails using IAlertNotifyHandler – Microsoft SharePoint Developer Documentation Team Blog – Site Home – MSDN Blogs

Configure alert settings for a Web application (SharePoint Foundation 2010)

Create an Alert for a List or Library

People Picker:

Getting your ‘People Picker’ to pick AD groups « SharePoint Internals – Hristo Pavlov’s Blog

All you want to know about People Picker in SharePoint ( Functionality | Configuration | Troubleshooting ) Part-2 – Lesson’s Learnt – Site Home – MSDN Blogs

Bharat Reddy Basani: Mysterious bug in SharePoint People Editor Control

No exact match found when adding users from different domains in SharePoint « Fast .NET


Resources: Other Programming related

Learn C The Hard Way A Clear & Direct Introduction To Modern C Programming

Searching and Navigating Code in VS 2010 (VS 2010 and .NET 4.0 Series) – ScottGu’s Blog


JavaScript for the C# Developer – Part 1 – Elumenotion Blog

JavaScript for the C# Developer Part 2 – Variables and Scoping Rules – Elumenotion Blog

JavaScript for the C# Developer Part 3 – Functions – Elumenotion Blog

Design Patterns:

Design Patterns | Object Oriented Design

Active Directory & C#:

Howto: (Almost) Everything In Active Directory via C# – CodeProject


String Format for Double [C#]

Custom Numeric Format Strings

PowerShell for developers – Waldek Mastykarz

Debugging in Visual Studio

10+ powerful debugging tricks with Visual Studio – CodeProject

Using Stopwatches and Timers in .NET

.NET Column: Calling Win32 DLLs in C# with P/Invoke