PictureBox and path for Virtual Directory

12 posts, 0 answers
  1. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 21 Oct 2013 Link to this post

    Hello

    I have a pictureBox in my telerik Report.

    If i use a real directory "multimedia" the path work , it's ok.

    cPath = "~/multimedia//logo.jpg";

    But if the directory Multimedia is virtual (cause i shared it for other project)
    the report don't find this picture.

    i have to use the complete path with domain to get this. "http://localhost/myproject/multimedia/logo.jpg"

    And in asp.net Webform , it's work , but in telerik report it doesn"t work.

    Have you any solution to give me.

    thanks
    Oliver
  2. Squall
    Squall avatar
    174 posts
    Member since:
    Feb 2011

    Posted 22 Oct 2013 Link to this post

    Hi, for relative paths you have they recommend this syntax:
    this.pictureBox4.Value = @".\images\MyPicture.png";//relative file path

    http://www.telerik.com/help/reporting/report-items-picture-box.html
  3. DevCraft banner
  4. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 22 Oct 2013 Link to this post

    Hi Squall ,

    i test this

    this.pictureBox4.Value = @".\images\MyPicture.png"

    and it's doesn't work for the virtual directory, i don't know why ? cause the server.mappath("~/multimedia/logo.jpg") work very well

    Olivier
  5. Unknown
    Unknown avatar
    21 posts
    Member since:
    Jan 2012

    Posted 25 Oct 2013 Link to this post

    You can try using not the relative path but the relative url, the last one in the examples.
  6. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 25 Oct 2013 Link to this post

    Hello ,

    the last on doesn't work cause the virtual directory isn't present at the root project directory

    The only way which works, i don't know why the report telerik work different way webform asp.net

    it's :

    using System.Drawing;
      
    Image image1 = Image.FromFile(@"C:\MyPictures\MyPicture.jpg");
    this.pictureBox1.Value = image1;

    Olivier
  7. Stef
    Admin
    Stef avatar
    3050 posts

    Posted 30 Oct 2013 Link to this post

    Hello Olivier,

    The issue is fixed in the upcoming internal build. Meanwhile, you can use user function to map the images on the server and set the PictureBox.Value property.

    Let us know if you need any further help.

    Regards,
    Stef
    Telerik

    Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

  8. ken
    ken avatar
    3 posts
    Member since:
    Apr 2011

    Posted 30 Oct 2013 Link to this post

    Hi Stef, I have a follow up question on your comment regarding "the upcoming internal build".

    I updated to Q3 2013 today (30 OCT 2013) and WebForms reports with relative paths in Picture boxes stopped working.  The thing that confused me is that the release notes for Q3 2013 states "FIXED: PictureBox does not resolve relative paths to the image".  But in my case they were working in Q2 2013 but no longer work in Q3 2013.

    The code in the report cs file that was previously working is:
    pictureBox1.Value = "/Content/Styles/Images/SchoolLogo.png";

    It now throws an error "could not find a part of the path...".

    Will the fix you mentioned in the upcoming internal build correct this?

    Additionally, where can I find details on the changed functionality that was applied to the PictureBox between Q2 2013 and Q3 2013?  I'd like to understand what changed around this space.

    Thanks,
    Ken

     

  9. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 30 Oct 2013 Link to this post

    Hello Stef,

    I will implement the user function, it's easy when we inherit from custom telerik reporting class base.

    ps : which version correct this bug ?


    thanks
    Olivier
  10. Stef
    Admin
    Stef avatar
    3050 posts

    Posted 04 Nov 2013 Link to this post

    Hello,

    In general, images are resolved on the server by getting the application root folder and mapping the relative path. This requires a knowledge of the level of the folder in the solution, so you can write a relative path (using dots and slashes) exiting to that level.

    The other suggested approach is to utilize user function and programmatically map the images folder.

    About the upcoming internal build, we have fixed an issue with relative paths related to specific use in projects. In order to verify if the fix applies to your case, we will need more details about the type of project, the solution structure and the use of the images. Notice the PictureBox.Value set to relative path will be resolved based on the running application root, thus you may not have proper design preview if the image is located in other projects.

    Regards,
    Stef
    Telerik

    Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

  11. AkAlan
    AkAlan avatar
    121 posts
    Member since:
    Jun 2009

    Posted 12 Nov 2013 Link to this post

    Stef, I also upgraded from Q2 2013 to Q3 2013 and my pictureboxes that were configured to use a relative path all broke. I had to change all my pictureboxes from relative url to absolute URL to get them back working. I spent most of the day trying to get the picturebox to work using a relative path

    My MVC 3 solution has a MainProject  and it references a ReportProject. The jpg files I want to use in my ReportProject are located in the MainProject in a folder called Images. So how do I reference them in my report picturebox1.value using a Relative Path? I have tried every iteration I could think of (including the examples from Telerik Documentation) and none seem to work. 





  12. Stef
    Admin
    Stef avatar
    3050 posts

    Posted 15 Nov 2013 Link to this post

    Hello Alan,

    Our aim is to be able to process images in a consistent way between different platforms. Thus the way we resolve relative paths is to have an unique way of recognizing relative paths by using '.' e.g. "./Images/SomeJPG.jpg". All relative paths are resolved based on the running application folder. This has to be considered while designing your report with the Standalone or VS Designer and displaying it in any Report Viewer. The documentation will be updated respectively with a consecutive release. If you follow this rule and still have issues, try to upgrade to the latest internal build Telerik Reporting Q3 2013 version 7.2.13.1105, where we have fixed an issue with relative paths to images when you use the new Reporting REST service.

    If changing the syntax of the image path is not possible, the best solution is to customize the way you set the PictureBox.Value with user function in binding, which allows to you apply any native for the used technology/project type/custom scenario approach to map relative paths.

    Let us know if you have any further questions.

    Regards,
    Stef
    Telerik

    New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

  13. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 15 Nov 2013 Link to this post

    Hello,

    the last version don't help me to correct the virtual path, but i have inherit all my herit from report base, and i add this custom method 'resolveUrl', it's work very well in this case.

    if it's help someone it ll be great.
Back to Top
DevCraft banner