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

Forums / Sitefinity SDK / Images not rendering in custom user controls

Images not rendering in custom user controls

3 posts, 0 answered
  1. Caedmon
    Caedmon avatar
    10 posts
    Registered:
    02 Feb 2011
    01 Mar 2011
    Link to this post
    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!
  2. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    01 Mar 2011
    Link to this post
    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 http://www.sitefinity.com/40/help/developer-manual/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();
  3. Caedmon
    Caedmon avatar
    10 posts
    Registered:
    02 Feb 2011
    01 Mar 2011
    Link to this post
    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!
3 posts, 0 answered