Monthly Archives: March 2013

Microsoft Code Samples for .NET, SharePoint and other MS Technologies

If you want some nice code samples on how to do things in different MS products and technologies visit this URL:


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

Resources: .NET and SharePoint Tools

Gary Lapointe – STSADM and PowerShell extensions for Sharepoint 2007, 2010 and 2013

SharePoint Manager 2010

Snippet Compiler

COBOL the Barbarian: Multi-Language .NET Snippet Compiler

SharePoint LogViewer – View ULS logs the easy and efficient way

SPSFarmReport – Home

Wireshark · Go deep.

Download LINQPad

HTML5 Boilerplate: The web’s most popular front-end template

Camlex.NET – Home

SharePoint Diagnostic Studio 2010 – Jeremy Taylor | Jeremy Taylor

Download SharePoint 2010 Administration Toolkit v2.0 from Official Microsoft Download Center

smtp4dev – Home

Announcing release of ASP.NET and Web Tools 2012.2 Update – ScottGu’s Blog


Fiddler Web Debugger – A free web debugging tool

Resources: SharePoint Search Center and Searching

SharePoint Server 2007 Search – How to create a fully functioning Search Center: Part 1 – UK SharePoint Team – Site Home – MSDN Blogs

SharePoint Server 2007 Search – How to create a fully functioning Search Center: Part 2

sharepoint.H@ck : Redirect Contextual Search Results to Search Centre Results Page

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

Configuring Scopes Dropdown | SharePoint Use Cases

Configuring scopes in Microsoft Search Server 2008 – Part 2 | SharePoint Use Cases

Chapter 3: Customizing and Extending the Microsoft Office SharePoint 2007 Search (Part 1 of 2)

Chapter 3: Customizing and Extending the Microsoft Office SharePoint 2007 Search (Part 2 of 2)

How to Search on Last Modified By field in SharePoint Advanced Search » SharePoint Insight

How to: Exclude part of a page from being indexed by SharePoint Search – Corey Roth

MOSS 2007: Customize the Search Result (using XSLT) – Tobias Zimmergren’s thoughts on development

MOSS 2007: Customizing the Search Results Page (XSLT) – Part 2 – Add highlighting – Tobias Zimmergren’s thoughts on development

Search for people – SharePoint Server – Microsoft Office

Excluding folders from search results in MOSS 2007 | Mrin’s Blog

What’s new for end users in SharePoint Search 2010

Customize the People Search Results – Part 2 | Sharepointology

Programmatically Disabling or Enabling Site Search Visibility « Geoff Varosky’s Blog

How to: Change the Properties Returned in the Core Search Results

SharePoint People Search – Lessons learned. Part 1: Covering the basics – Waldek Mastykarz

SharePoint People Search – Lessons learned. Part 2: Programmatically running search queries – Waldek Mastykarz

Using Enterprise Search Property Filters in SharePoint Server 2007

Using the SharePoint Search API with URL Query String Parameters – SharePoint for End Users

Mystery Solved – Crawled Properties in SharePoint (Part 1) – Anne Stenberg’s Blog – Site Home – TechNet Blogs

Enterprise Search SQL Syntax Reference

WSS Custom Search – The Bamboo Team Blog – Bamboo Nation

Leverage Search Crawl rules and Content Class property to refine SharePoint Search result « Chris’s SharePoint Reflections

Indexing pdf documents with Adobe Reader v.8 and MOSS 2007 – Filter Central – Site Home – MSDN Blogs

Index PDF documents on SharePoint using Adobe PDF IFilter 9 – Harold van de Kamp’s Blog

Excluding Various SharePoint Items from Search Results on Internet-Facing MOSS Sites – Random Musings of Jeremy Jameson – Site Home – MSDN Blogs

Contentclass Property

Limiting the Search Scope using contentclass in a Property Query Scope Rule «                    Are you a user?

SharePoint Server 2007 Search – How to create a fully functioning Search Center: Part 2 – The SharePoint Guys – Site Home – MSDN Blogs