More in this section

Forums / Developing with Sitefinity / Can't Display Image on Public Control

Can't Display Image on Public Control

2 posts, 0 answered
  1. First Last
    First Last avatar
    2 posts
    02 Jul 2009
    06 Aug 2009
    Link to this post
     I'm trying to attach two (2) images and one (1) document to a Generic_Content-based modules. Despite being new to .NET, I'm been 80% of the way there, but can't get the image to display on the public side.


    I've set up the data model in web.config:

    <add key="Locations.Thumbnail" valueType="ShortText" visible="True" searchable="True" sortable="False" defaultValue=""/>  
    <add key="Locations.Document" valueType="ShortText" visible="True" searchable="True" sortable="False" defaultValue=""/> 

    I've added the fields to the admin add/edit controls:

    <li class="selector">  
       <asp:Label ID="Label8" AssociatedControlID="Thumbnail" runat="server">  
          <asp:Literal ID="Literal25" runat="server" Text="<%$Resources:Thumbnail %>"></asp:Literal> <em id="ThumbnailLabel" runat="server"></em> 
       <asp:TextBox ID="Thumbnail" Text="" runat="server" MaxLength="250"></asp:TextBox> 
          <sfLib:ButtonSelector WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx" ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx" AssociatedControls="Thumbnail" runat="server" cssclass="pickerWrapper" ButtonText="<%$Resources:ThumbnailSelect%>" /> 
    <class="example"><asp:Literal ID="Literal26" runat="server" Text="<%$Resources:ThumbnailNote %>"></asp:Literal></p>  

    Data is being stored -- although in cryptic code vs. thumbnail previews:




    But I cannot display the image through the public control. I'm using the correct template, since I see a broken image icon. What returns is either a blank image or [Libraries] string above depending on how I request the variable:

    <asp:Image ID="Thumbnail" runat="server" /> -or- <asp:Literal ID="Thumbnail" runat="server" /> 

    So, what's the real way to embed an image?



  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    07 Aug 2009
    Link to this post
    Hi First Last,

    1. In the Sitefinity's front end you should use SitefinityImage control, which automatically resolve the ImageUrl property from [PROVIDER]Guid to url.

    Sample code:

    <%@ Register TagPrefix="sf" Assembly="Telerik.Cms.Engine" Namespace="Telerik.Cms.Engine.WebControls" %> 
    <sf:SitefinityImage  ID="SitefinityImage1" runat="server" ImageUrl="TYPE ID AND PROVIDER HERE" /> 

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered