Skip to content

Instantly share code, notes, and snippets.

AmitKB / sp2010-proj-dashboard
Created Oct 10, 2014
SharePoint 2010 Project Tasks list dashbaord
View sp2010-proj-dashboard
<?xml version="1.0" encoding="UTF-8"?>
Date: 03-Oct-2014
Purpose: Show project plans in customized way to be presented on dashboard
<xsl:stylesheet xmlns:xsl=""
<xsl:include href="/_layouts/xsl/main.xsl"/>
AmitKB / US to ISO date format
Last active Dec 20, 2015
This converts the date format in mm/dd/yyyy to ISO date format to be used in MOSS 2007 / WSS 3.0
View US to ISO date format
function ISODateString (stringDate){
function pad(n){return n<10 ? '0'+n : n}
function parseDate(input) {
var parts = input.split('/');
var y = parseInt(parts[2]);
var m = parseInt(parts[0]);
var d = parseInt(parts[1]);
View SharePoint 2010 ULS Logging
using System;
using System.Collections.Generic;
using Microsoft.SharePoint.Administration;
namespace MyLoggingApp
public class UlsLogging : SPDiagnosticsServiceBase
// Product name
private const string PRODUCT_NAME = "My Custom Solution";
AmitKB / String to title case
Last active Dec 18, 2015
Make a string title or proper case
View String to title case
public static class StringHelper
public static string ToTitleCase(this string s)
// Return empty if input is null or empty
if (string.IsNullOrEmpty(s)) return string.Empty;
// This will hold our processing value
// and finally have string in title case.
var sb = new StringBuilder();
View SPFilterUsingView
private SPListItemCollection GetItemsUsingView()
// Get view
var list = SPContext.Current.Web.Lists.TryGetList("[MyList]");
var view = list.Views["[MyView]"];
#region Get "Where" filter expression from list view
// Get the filter expression from view
string filterCaml = string.Empty;
View RemoveHtmlStuffs
// Converts the html text to plain text
public static string RemoveHtmlStuffs(string htmlText)
var rx = new Regex(@"<(.|\n)*?>");
return SPEncode.HtmlDecode( // remove characters like &nbsp;, &amp; etc
rx.Replace(htmlText, string.Empty) // remove html tags lik <p>,<div> etc
AmitKB / UrlParamterAddUpdate
Created Oct 1, 2012
Add / Update url paramter
View UrlParamterAddUpdate
public static string AddToUrlQuerystring(HttpRequest req, string paramName, object paramValue, bool encodeValue)
var sb = new StringBuilder();
string ParamValue;
// Encode parameter value or not
if (encodeValue)
ParamValue = SPEncode.UrlEncode(paramValue.ToString());
ParamValue = paramValue.ToString();
You can’t perform that action at this time.