More in this section

Forums / General Discussions / Showing pdf icons

Showing pdf icons

3 posts, 0 answered
  1. Rene
    Rene avatar
    25 posts
    02 Feb 2009
    06 Sep 2010
    Link to this post

    If I show a document list, is it possible to show the icons of the document types? For example if you have a list with only pfd documents, is it possible to show the pdf icons with all the documents?

    Just wondering.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    06 Sep 2010
    Link to this post
    Hi Rene,

    Yes it is possible. Create a custom control that inherits from DownloadList. Then override SetListMetadata method from where you have access to the IContent item. Then check the mimetype of the IContent item and set a proper image to it. In the template you could add an Image control and inside SetListMetadata you can set the Image url depending on the type of the file.

    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Chris
    Chris avatar
    57 posts
    12 Nov 2008
    08 Sep 2010
    Link to this post
    Although this is a solution, there's a much simpler one (that doesn't require a custom control):
    - Edit the web.config so that library links are created in a way that includes the file type, e.g:
    <cmsEngine defaultProvider="Generic_Content">
            <add name="Libraries" urlRewriteFormat="~/{Provider}/{LibraryName}/[Name]_[Extension].sflb.ashx" .../>
    (I added the _[Extension] part)

    - Use CSS to style the download links accordingly:
    .LinkPdf {
        padding: 0 0 0 20px;
        background-image: url('./Images/link_pdf.gif');
        background-position: center left;
        background-repeat: no-repeat;

    Note: You will have to use a little bit of JavaScript to make this work in IE6 (which doesn't support CSS attribute selectors):
    //Make the Telerik jQuery variable available globally
    var jQuery = window.jQuery = window.$ = $telerik.$;
    //CSS fixes for IE6 that cannot be done with standard CSS selectors
    if ($.browser.msie && $.browser.version < 7) {
        $(document).ready(function() {
            //Apply CSS attribute selectors for document links
            $("a[href$='.pdf']").before('<span class="DocLink LinkPdf">&nbsp;&nbsp;&nbsp;&nbsp;</span>');
            $("a[href$='_pdf.sflb.ashx']").before('<span class="DocLink LinkPdf" >&nbsp;&nbsp;&nbsp;&nbsp;</span>');

Register for webinar
3 posts, 0 answered