PictureBox error if image not found

12 posts, 0 answers
  1. Hans Werner
    Hans Werner avatar
    3 posts
    Member since:
    Oct 2009

    Posted 19 Nov 2009 Link to this post

    Hello Telerik Team,
    i'm evaluating your great reporting product, but i have some little problems and i hope to find some help here.

    I've draged a PictureBox into my report (detail section) and made the following Expression to load a harddrive stored picture into it:

    = Format("C:\ProductPictures\{0}.jpg", Fields.articleNo) 

    This is working perfectly as long as the picture with the filname "articleNo+.jpg" exists in the given harddrive folder. If there isn't a picture for the specific article (which is a common situation for our needs), i get the following error in the report output (for every not existing picture in a list with 5000 articles ...): 
    "An error has occured while processing PictureBox "pictureBox1': The File "C:\ProductPictures\ART00001.jpg" could not be found."

    Is there a way to supress the error message if the picture doesn't exists? We don't need and want this error message =)

    Best Regards from Germany
    Hans
  2. Hans Werner
    Hans Werner avatar
    3 posts
    Member since:
    Oct 2009

    Posted 19 Nov 2009 Link to this post

    No ideas for solving this problem?
  3. Hans Werner
    Hans Werner avatar
    3 posts
    Member since:
    Oct 2009

    Posted 19 Nov 2009 Link to this post

    Here a possible solution for everyone lookin for:

    Make a user function:
    public static String PicturePath(String sCompletePath) 
            { 
                String sFinalPath = ""
     
                if (File.Exists(sCompletePath)) 
                    sFinalPath = sCompletePath; 
                else 
                { 
                    String sCurrentAppDirectory = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath); 
                    sFinalPath = sCurrentAppDirectory + "\\default.jpg"
                } 
     
                return sFinalPath; 
            } 

    In the picturebox expression, extend the statement from
    = Format("C:\ProductPictures\{0}.jpg", Fields.articleNo)  
    to
    = TelerikReportTutorial.ArticleList.PicturePath(Format("D:\Work\OBI\Artikel-Bilder\{0}.jpg", Fields.articleNo)) 

    And everything works fine. You just need to create a 1x1 pixel default.jpg image in your app directory which will be used if the other picture doesn't exist.

    Have fun!








  4. Rafa
    Rafa avatar
    11 posts
    Member since:
    Aug 2014

    Posted 15 Jan 2015 Link to this post

    Hi,

    Is there any official solution for this yet?

    Regards,
    Rafa
  5. KS
    KS avatar
    165 posts
    Member since:
    Oct 2012

    Posted 20 Jan 2015 in reply to Rafa Link to this post

    Hi,

    User functions do the work for me and let me check if the image exists on the server. Maybe you are searching for some error handling like with Report.Error event.

    -KS
  6. Rafa
    Rafa avatar
    11 posts
    Member since:
    Aug 2014

    Posted 11 Feb 2015 in reply to KS Link to this post

    Hi KS,

    Yes, currently I am using user function similar to Hans Werner's post above. But I wonder if  a built in function for this will be available sooner or later.

    Regards, 
    Rafa
  7. KS
    KS avatar
    165 posts
    Member since:
    Oct 2012

    Posted 16 Feb 2015 in reply to Rafa Link to this post

    Hi,

    Sounds like a feature request. I think this is a matter of error handling (to have a missing image is an unexpected behavior resulting in an error) and there is no common solution. Sometimes it is better to have a default image instead of a blank space or broken image. Sometimes blank space is the expected result.

    -KS
  8. doli
    doli avatar
    13 posts
    Member since:
    May 2016

    Posted 09 Dec 2016 Link to this post

    Hi 

    please find attached file,

    I need to put image from the url and conditionally like "intead of 50/93.75/100% replace all of those with either thumbs
    up/down(image). If greater than 50% then it's thumbs up and if its 50% or less its thumbs down (image)"

    I need to replace image to 50 % .

    my expression is =IIf(Fields.Allowed_to_Miss < Fields.W,"50"+"%",cDbl(Fields.R) / cDbl(Fields.R + Fields.W))

    Please help. Thank you in advance.

    Thanks,

    Doli

     

  9. doli
    doli avatar
    13 posts
    Member since:
    May 2016

    Posted 09 Dec 2016 in reply to doli Link to this post

    Is anybody here please help me.
  10. doli
    doli avatar
    13 posts
    Member since:
    May 2016

    Posted 17 Mar Link to this post

    Hi
    Can you please help me?
    when we generate PDF we get error for picturebox.
    An error has occurred while processing PictureBox 'pbxPMPic':
    Invalid image data.
    ------------- InnerException -------------
    The remote server returned an error: (404) Not Found
    We have used URL of image like 
    ='http://mellowedout.zap-drd.com/images/' + iif(Fields.PMPic='', 'clearpix.gif', 'inspections/' + Parameters.InspectionId.Value + '/' + Fields.PMPic)
    in the report.

    you can check with attach file. 
  11. Stef
    Admin
    Stef avatar
    3539 posts

    Posted 21 Mar Link to this post

    Hello doli,

    You can use the same expression as TextBox item's Value property to check ho wit is resolved. You can also test the produced URL in browser and edit the URL to get the correct address of the image resource.

    I hope this helps.

    Regards,
    Stef
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  12. doli
    doli avatar
    13 posts
    Member since:
    May 2016

    Posted 21 Mar in reply to Stef Link to this post

    I have checked URL in broweser its working but when I put on picture box its giving me error like below

    http://mellowedout.zap-drd.com/images/clearpix.gif

    Invalid image data.
    ------------- InnerException -------------
    The remote server returned an error: (404) Not Found
Back to Top