Images not shown in custom widget

Posted by Community Admin on 05-Aug-2018 12:45

Images not shown in custom widget

All Replies

Posted by Community Admin on 23-Aug-2011 00:00

I created an image slider (jquery) which should slide through my product images. I use the following code:

protected void Page_Load(object sender, EventArgs e)
 
            if (!IsPostBack)
                rptProductSlider.ItemDataBound += new RepeaterItemEventHandler(rptProductSlider_ItemDataBound);
                BindData();
            
        
 
        void rptProductSlider_ItemDataBound(object sender, RepeaterItemEventArgs e)
 
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
 
                Product p = e.Item.DataItem as Product;
                 
                var imgProduct = e.Item.FindControl("imgProduct") as Image;
                imgProduct.ImageUrl = p.ThumbnailUrl;
                imgProduct.AlternateText = p.ThumbnailAlternativeText;
            
        
 
        private void BindData()
             
            var manager = CatalogManager.GetManager();
            this.rptProductSlider.DataSource = manager.GetProducts();
            this.rptProductSlider.DataBind();
        

For some reason the slider shows the default image instead of the image that I uploaded with my products.
/SFRes/images/Telerik.Sitefinity.Resources/Images.DefaultProductTmb.png

What am I doing wrong? The ProductList control that comes with the ECommerce module, is showing the images without a problem?

Regards,
Daniel

Posted by Community Admin on 23-Aug-2011 00:00

Hi Daniel,

You'll need to call CatalogManager's "PopulateImages" function on the list of Products that are returned from "GetProducts". Alternatively, you can call "SetProductImages" on each Product returned from "GetProducts".

Regards,
Tom

Posted by Community Admin on 25-Aug-2011 00:00

Can't figure out what 'provider' I have to fill in with this method. The SetProductImages() works okay, though...

Posted by Community Admin on 25-Aug-2011 00:00

Passing an empty string for that parameter will be fine in most cases.

Posted by Community Admin on 29-Aug-2011 00:00

Hm... doesn't work, unfortunately.

Posted by Community Admin on 31-Aug-2011 00:00

Hi Daniel Plomp,

The solution that Daniel suggested will work. I am also providing you a small sample attached to this reply where I demonstrated how you would get list of Products with Images.

Let me know if you are still facing any issues, and I will be glad to help.

Kind regards,
Venkata Koppaka
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

This thread is closed