Hi,
Using document library when we upload a document suppose if we upload a pdf document . You can see a small pdf icon.
Based on the document type the icons will map in Default Document Library in SharePoint 2013.
Similarly we need to get that while doing programmatically for that we can make use of SPUtility.MapToIcon
The original location of icons in the server will be at: C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\IMAGES
while in program the path will be like:http://doaminname:portnumber/_layouts/images/icdoc.png
string icon = SPUtility.ConcatUrls(“/_layouts/images”,SPUtility.MapToIcon(item.Web, SPUtility.ConcatUrls(objSPListItem.Web.Url, objSPListItem.Url), “”, IconSize.Size16));
Use Image Control in ASP.net
then
assign the
Image.Url=objSPListItem.Web.Url + icon;
Then you will get the icon related to the document type.
Note: SPUtility in sharepoint 2013 is a wonderful class which includes many useful methods.
Visit for more info: SPUtility
Your code is missing “15/” before “images” folder. As a result it will reference images of 2010 sharepoint from 14 hive.
For sharepoint version – independent code you should use SPUtility.ContextLayoutsFolder instead of “_layouts”
string icon = SPUtility.ConcatUrls(SPUtility.ConcatUrls(SPUtility.ContextLayoutsFolder, “images”), SPUtility.MapToIcon(item.Web, SPUtility.ConcatUrls(objSPListItem.Web.Url, objSPListItem.Url), “”, IconSize.Size16));