Decoding Query String with Unicode Characters

Recently I came across an issue where the query string had unicode characters and ASP.NET’s “HttpUtility.UrlDecode” was not properly converting the characters. After searching few minutes came across the following solution posted by cjsharp1 at Stackoverflow.

private string GetQueryStringValueFromRawUrl(string queryStringKey)
{
    var currentUri = new Uri(HttpContext.Current.Request.Url.Scheme + "://" + 
        HttpContext.Current.Request.Url.Authority + 
        HttpContext.Current.Request.RawUrl);
    var queryStringCollection = HttpUtility.ParseQueryString((currentUri).Query);
    return queryStringCollection.Get(queryStringKey);
}

Copy current item ID to clipboard using SharePoint custom action

Recently I had a requirement where the user needed to copy an item’s URL to clipboard in SharePoint.

Using the SharePoint designer, I created a Custom Action and in the “Navigate to URL” action type I set the following.

javascript:clipboardData.setData("Text", window.location.protocol+'//'+window.location.hostname+':'+window.location.port +'/sites//Lists//DispForm.aspx?ID='+'{ItemId}');alert('Item URL \"'+window.location.protocol+'//'+window.location.hostname+':'+window.location.port +'/sites//Lists//DispForm.aspx?ID='+'{ItemId}'+'\" copied to clipboard');