Images not rendering in custom user controls - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Images not rendering in custom user controls

  • Images not rendering in custom user controls
  • Here's the situation.  I am creating a new custom control that will display Event information based on a parameter passed to it.  So, I create an Event and place an image in the Description.  This image is stored in the default album and the WYSIWYG editor inserted the following HTML:

    <strong>Type your content here...</strong>
    <p><img alt="" src="/images/default-album/2011/03/01/Caedmon2.jpg" sfref="[images]8c1cfdbf-72eb-4fa0-ae0f-77b6e4844d61" /> </p>

    Now, I publish this and continue on my way.  When I access the page that is displaying my custom user control, I am displaying the Description (Content) field as an asp:Label.  So the front-end is a simple asp:Label:

    <asp:Label ID="lbDescription" runat="server"></asp:Label>

    And the backend is just assigning the Content property of the Event object to it:

    private void LoadInterface(String ID)
        EventsManager manager = new EventsManager();
        Event eventObj = manager.GetEvent(new Guid(ID));
     
        lbDescription.Text = eventObj.Content;           

    The image is rendered as follows:

    <img alt="" src="[images]8c1cfdbf-72eb-4fa0-ae0f-77b6e4844d61">

    Obviously this does not point to an image.  Do I need to render the Content property differently, or using another property or method elsewhere?

    Thanks guys!
  • You can try retrieving the MediaURL to display your image. This is a good article in how to retrieve the image you are looking for www.sitefinity.com/.../modules-built-in-modules-api-media-modules-images-managing-images-finding-images.html

    <asp:Image ID="MediaURLImage1" runat="server"  />


    Telerik.Sitefinity.Libraries.Model.Image myImage = new Telerik.Sitefinity.Libraries.Model.Image();
     
    MediaURLImage1.ImageUrl = myImage.MediaUrl.ToString();
  • Thanks for the reply!  Actually, I got it.  I was viewing the control in Preview mode.  Once the page is published the content is rendered correctly.

    Thanks again!