I was trying to load an image on a <asp:image> control.
The thing is that the paths of the images are saved in the database, and some of the image names contain white spaces. For example “Image name number 2.jpg”.
When I’m setting the ImageUrl attribute for the asp control, it can be assigned without any trouble, but when loaded in html the url is displayed as seen below:
"C:\..\..\Image%20name%20number%202.jpg"
Because of those “%20” it can’t find the picture so it won’t show.
What can I do to solve this?
The
%20part is actually the space character. You can easily remove it by passing the URL todecodeURI()in javascript:You can read more about it here: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURI
The opposite of
decodeURI()isencodeURI():You can read more about it here: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURI