Skip to content

Instantly share code, notes, and snippets.

@AmitKB
AmitKB / sp2010-proj-dashboard
Created October 10, 2014 19:11
SharePoint 2010 Project Tasks list dashbaord
<?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="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">
<xsl:include href="/_layouts/xsl/main.xsl"/>
@AmitKB
AmitKB / US to ISO date format
Last active December 20, 2015 02:09
This converts the date format in mm/dd/yyyy to ISO date format to be used in MOSS 2007 / WSS 3.0
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]);
@AmitKB
AmitKB / SharePoint 2010 ULS Logging
Created June 30, 2013 10:54
SharePoint 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
AmitKB / String to title case
Last active December 18, 2015 00:28
Make a string title or proper 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();
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;
// 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
AmitKB / UrlParamterAddUpdate
Created October 1, 2012 15:28
Add / Update url paramter
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());
else
ParamValue = paramValue.ToString();