This documentation is archived and is not being maintained.

MapToIcon Element

SharePoint 2003

The MapToIcon element returns the file name of the icon associated with a given file name extension and ProgID.

Syntax

<MapToIcon>
   ProgID|File_Extension
</MapToIcon>

Remarks

The MapToIcon element uses the following syntax, separating the ProgID from the file name extension with a pipe symbol ("|"):

<MapToIcon>ProgID|File_Extension </MapToIcon>

This element can be used in any rendering scenario (for example in a view, or as stand-alone element in a document), but it is most useful in a view of a document library.

For example, <MapToIcon>|xls</MapToIcon> renders the Microsoft Excel .gif file defined within the ByExtension element of the DOCICON.XML file, and <MapToIcon>Excel.Sheet|htm</MapToIcon> would render the Excel .gif file defined in the ByProgID element of DOCICON.XML, but <MapToIcon>CustomApp.Baz|htm</MapToIcon> would render the generic HTML icon because the ProgID, "CustomApp.Baz," is unknown.

Note that the set of file name extensions and ProgIDs that are supported are extensible by the system administrator. They can be edited in DOCICON.XML, and then the image files can be included in the Templates/1033 directory. After such a modification, Microsoft Internet Information Services (IIS) needs to be restarted. Subsequently, any new Web sites based on Microsoft Windows SharePoint Services will support the new file types and display the correct icons. The number of icons and ProgIDs that can be supported is limited only by system resources (memory and disk space).

Example

The following example creates the linked application icon that appears on the toolbar in the Edit Properties view for a document library item. The example uses the MapToIcon element to construct the URL of the icon based on the file extension of the document and the ProgID of the application associated with the document.

<HTML><![CDATA[
   <a tabindex=2 class="ms-toolbar" target=_self href="javascript:"
    onclick="javascript:editDocumentWithProgID2(' ]]>
</HTML>
<ScriptQuote NotAddingQuote="TRUE">
   <Field Name="ServerUrl" URLEncodeAsURL="TRUE" />
</ScriptQuote>
<HTML><![CDATA[ ',' ]]></HTML>
<GetVar Name="ProgID" />
<HTML><![CDATA[ ',' ]]></HTML>
<GetVar Name="Editor" />
<HTML><![CDATA[ ');javascript:return false;" ACCESSKEY=I ID=diidEditItem>
   <IMG BORDER=0 ALT=" ]]>
</HTML>
<HTML>Icon</HTML>
<HTML><![CDATA[ " SRC=" ]]></HTML>
<ImagesPath />
<MapToIcon>
   <Column Name="HTML_x0020_File_x0020_Type" />
   <HTML>|</HTML>
   <Column Name="File_x0020_Type" />
</MapToIcon>
<HTML><![CDATA[ "></a>]]></HTML>

Show: