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

Display SVG Files

1 Answer 264 Views
BinaryImage
This is a migrated thread and some comments may be shown as answers.
Klemens
Top achievements
Rank 1
Klemens asked on 13 Nov 2013, 09:29 AM

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 14 Nov 2013, 12:13 PM
Hi Peter,

When you set the image as ImageUrl, the RadBinaryImage only resolve the path to the image, and it is directly shown in your browser.

When you bind the data, the image is hosted and then shown in the browser. There are several reasons for this not to work:
1. You don't have to call the DataBind, just assign the DataValue. Because DataBind will bind the control from it's parent, and it could even set new DataValue when binding, and clears yours.
2. The required HTTP handlers are missing from your web config. Check this help topic to see how to add them: http://www.telerik.com/help/aspnet-ajax/binaryimage.html
3. The data in the file is corrupted, incomplete or not in correct format.

To confirm that 3 is not the problem, you could read the files as Image:
http://msdn.microsoft.com/en-us/library/4sahykhd%28v=vs.110%29.aspx
And then convert the image back to byte and set it to the RadBinaryImage.
System.IO.MemoryStream stream = new System.IO.MemoryStream();
 
Image YourImage = Image.FromFile (your_file_name,true);
 
YourImage.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
 
image.DataValue = stream.ToArray();
You could debug the lines above after adding it in your page and see if the image is correct.

Regards,
Vasil
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
BinaryImage
Asked by
Klemens
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or