This is a migrated thread and some comments may be shown as answers.

PictureBox and path for Virtual Directory

11 Answers 974 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Olivier
Top achievements
Rank 2
Olivier asked on 21 Oct 2013, 09:37 AM
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

11 Answers, 1 is accepted

Sort by
0
Squall
Top achievements
Rank 1
answered on 22 Oct 2013, 09:03 AM
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
0
Olivier
Top achievements
Rank 2
answered on 22 Oct 2013, 03:16 PM
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
0
Unknown
Top achievements
Rank 1
answered on 25 Oct 2013, 03:22 PM
You can try using not the relative path but the relative url, the last one in the examples.
0
Olivier
Top achievements
Rank 2
answered on 25 Oct 2013, 03:25 PM
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
0
Stef
Telerik team
answered on 30 Oct 2013, 01:03 PM
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.

0
ken
Top achievements
Rank 1
answered on 30 Oct 2013, 07:52 PM

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

 

0
Olivier
Top achievements
Rank 2
answered on 30 Oct 2013, 08:01 PM
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
0
Stef
Telerik team
answered on 04 Nov 2013, 03:10 PM
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.

0
AkAlan
Top achievements
Rank 2
answered on 13 Nov 2013, 12:14 AM
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. 





0
Stef
Telerik team
answered on 15 Nov 2013, 12:05 PM
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.

0
Olivier
Top achievements
Rank 2
answered on 15 Nov 2013, 01:34 PM
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.
Tags
General Discussions
Asked by
Olivier
Top achievements
Rank 2
Answers by
Squall
Top achievements
Rank 1
Olivier
Top achievements
Rank 2
Unknown
Top achievements
Rank 1
Stef
Telerik team
ken
Top achievements
Rank 1
AkAlan
Top achievements
Rank 2
Share this question
or