Category Archives: JavaScript

Ribbon missing on SharePoint List or Library page SharePoint 2013

This article is related to below post where user reported missing ribbon issue after migration from SharePoint 2007 to 2013 version.


Ribbon not visible on SharePoint List/Library page load. Mostly reported after site migration from 2007 to 2010/2013 version. Also if you have added a content editor web part on this page.


01.<scripttype="text/javascript"src=" "></script>
04.var elem = document.getElementById("MSOZoneCell_WebPartWPQ2");
05.           if(elem != null) {
06.                var dummyevent = new Array();
07.                dummyevent["target"] = elem;
08.                dummyevent["srcElement"] = elem;
09.                WpClick(dummyevent);
10.                _ribbonStartInit("Ribbon.Browse", true)
11.            }
12. });

Get icon for different file types SharePoint2010

If you are working in custom search and your search result in returning various file types like

html, pdf, excel or word etc. and you want to show a small icon for corresponding file types then this article will help you.

This function will take parameter as the itemURL and it will return corresponding icon URL. MapToIcon function of SPUtility class will give us the iconURL.

private string GetIconURL(string itemURL)
string iconURL = string.Empty;

iconUrl = “/_layouts/images/” + SPUtility.MapToIcon(SPContext.Current.Web, itemURL, string.Empty, IconSize.Size16);

return iconURL;