1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Picture icon Document in How to View the icon (image) of the document type in "DownloadList.ascx"

Picture icon Document in How to View the icon (image) of the document type in "DownloadList.ascx"

7 posts, 0 answered
  1. Cyril Wasem
    Cyril Wasem avatar
    20 posts
    Registered:
    04 Aug 2009
    17 Sep 2009
    Link to this post
    Hello
    How i can display the icon (picure) of the document type in "DownloadList.ascx" like {img}.pdf ?

    Thks

    Cyril
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    17 Sep 2009
    Link to this post
    Hi Cyril Wasem,

    The easiest way will be creating a new metakey which stores the url of your image. Then modify DownloadList template and add Image control with the same ID of your metakey name.

    Another option is overriding DownloadList control and getting the extension of each item in the list. The show an appropriate image. This will not require creating a metakey and assiging an image to each item.
    You can use switch case block for different extensions.

    Sample code:

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using Telerik.Libraries; 
    using System.ComponentModel; 
    using System.Drawing.Design; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
     
    /// <summary> 
    /// Summary description for DownloadList 
    /// </summary> 
    ///  
     
    public class CustomDownloadListToolboxItem : ToolboxItem 
     
        public CustomDownloadListToolboxItem() 
            : base(typeof(CustomDownloadList)) 
        { 
            base.DisplayName = "DisplayName"
            base.Description = "DownloadList_Description"
        } 
     
    [ToolboxItem(typeof(CustomDownloadListToolboxItem))] 
    public class CustomDownloadList : DownloadList 
        public CustomDownloadList() 
        { 
     
        } 
     
        public override string ItemListTemplatePath 
        { 
            get 
            { 
                return "~/Sitefinity/ControlTemplates/Libraries/DownloadList.ascx"
            } 
     
        } 
     
        protected override void SetItemMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem) 
        { 
            base.SetItemMetadata(itemContainer, contentItem); 
            Image myImage = (Image)itemContainer.Controls[0].FindControl("Extension1"); 
            if (myImage != null
            { 
                myImage.ImageUrl = "~/Files/Bluetooth.jpg"
            } 
        } 
     


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Cyril Wasem
    Cyril Wasem avatar
    20 posts
    Registered:
    04 Aug 2009
    17 Sep 2009
    Link to this post
    When i upload a file by images&document you have the file type of the document.
    like : look : http://exchange.pixit.com:8000/pdf.jpg

    i don't like upload a picture for each document by use your embeded icon....

    Can i ? 


  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    17 Sep 2009
    Link to this post
    Hi Cyril Wasem,

    The serer behind the link you sent does not respond. Could you update it please?

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Cyril Wasem
    Cyril Wasem avatar
    20 posts
    Registered:
    04 Aug 2009
    17 Sep 2009
    Link to this post
    hi,

    sorry, the server was down...

    look here : http://www.radiojazz.ch/pdf.jpg


    best regards
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    17 Sep 2009
    Link to this post
    Hi Cyril Wasem,

    The images are located under Sitefinity/Admin/Themes/Default/Images. For instance the pdf image name is "a_pdf" so you can replace it or easily access it using the custom control I sent you. Note that these images are used in ~/Sitefinity/Admin/Themes/Default/global1.css and ~/Sitefinity/Admin/Themes/Default/Modules.css

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Cyril Wasem
    Cyril Wasem avatar
    20 posts
    Registered:
    04 Aug 2009
    17 Sep 2009
    Link to this post
    HI
    thks's it's work fine:

    <

     

    img alt="" src="../images/a_<%# DataBinder.Eval(Container.DataItem, "Extension").ToString().Substring(1,DataBinder.Eval(Container.DataItem, "Extension").ToString().Length-1)%>.gif" height="16px" width="16px" border="0" />

    Cyril

     

Register for webinar
7 posts, 0 answered