Unfortunately, even thought the imageurl of the image control has nothing set, and it is being set to this temporary image path it doesn't display on my page. The visibility of the control is set to true. I'm at a loss as it doens't error out, it doesn't
spit it's dummy it just won't display the image.
I want to store the images on the server, I don't want them stored on the client. That's why I'm using Server.MapPath(). Asp:Image doesn't have a "Url" property.
When I remove the Server.MapPath() and just pass in "~/images/image.png" I get a FileNotFoundException when I get Image From File.
Probably making a beginners mistake.
*edit* Ok, fixed it, you need the server.map path everywhere you are referring to the "FILE" if you want to assign the stored image to the image control, then you have to pass in a url.
d347hm4n
Member
30 Points
28 Posts
Assigning a manipulated image to asp:Image control
Jul 11, 2011 03:02 PM|LINK
Hello folks,
I'm manipulating an image on the fly on my web page.
WebClient wc = new WebClient(); string path = Server.MapPath(@"~/Some/path/image.png"); System.Drawing.Image bmp = System.Drawing.Image.FromFile(path,true); Graphics g = Graphics.FromImage(bmp);So I do my manipulation on G, Once I have drawn what I want to draw on my image, I save it to a file, then load that file into my image control.
MemoryStream tempStream = new MemoryStream(); bmp.Save(tempStream,System.Drawing.Imaging.ImageFormat.Png); FileStream outStream = File.OpenWrite(Server.MapPath(@"~/Some/path/image_temp.png")); tempStream.WriteTo(outStream); outStream.Flush(); outStream.Close(); imgAbsRiskBar.ImageUrl = Server.MapPath(@"~/Some/path/image_temp.png");Unfortunately, even thought the imageurl of the image control has nothing set, and it is being set to this temporary image path it doesn't display on my page. The visibility of the control is set to true. I'm at a loss as it doens't error out, it doesn't spit it's dummy it just won't display the image.
Any help would be greatly appreciated.
Menno van de...
Contributor
2764 Points
391 Posts
Re: Assigning a manipulated image to asp:Image control
Jul 11, 2011 07:25 PM|LINK
Server.Mappath() maps to the local filesystem path. You appear to be assigning that path to the ImageUrl property, rather than the url.
Menno
d347hm4n
Member
30 Points
28 Posts
Re: Assigning a manipulated image to asp:Image control
Jul 12, 2011 08:08 AM|LINK
I want to store the images on the server, I don't want them stored on the client. That's why I'm using Server.MapPath(). Asp:Image doesn't have a "Url" property.
Menno van de...
Contributor
2764 Points
391 Posts
Re: Assigning a manipulated image to asp:Image control
Jul 12, 2011 12:04 PM|LINK
Your image is already stored The ImageUrl property needs an url, not a local path. That's why it's ImageUrl rather than ImageFilePath.
Menno
d347hm4n
Member
30 Points
28 Posts
Re: Assigning a manipulated image to asp:Image control
Jul 12, 2011 01:07 PM|LINK
When I remove the Server.MapPath() and just pass in "~/images/image.png" I get a FileNotFoundException when I get Image From File.
Probably making a beginners mistake.
*edit* Ok, fixed it, you need the server.map path everywhere you are referring to the "FILE" if you want to assign the stored image to the image control, then you have to pass in a url.
Thanks very much, learn something new everyday.
sudha4999
Member
2 Points
1 Post
Re: Assigning a manipulated image to asp:Image control
Oct 12, 2012 07:27 AM|LINK
I am facing the same issue ... can anyone explain me what should i do to load that image to my imgurl??