I have a list of JPG's which are found in a SQL Server database. When the
page selects a certain piece of data it will refer to the file system
(resident on IIS server with a virtual directory) and files contained within
a certain folder. I have been trying for quite a while to set the ImageURL
of an image control to the correct information.
I have googled till my mind hurts but can find nothing to help. I have even
tried to copy the jpg file to a temppics folder under my site to make that
work with no luck. Just the gif showing the file does not exist.
For example this is the filename of one of the jpgs:
D:\My Music\Classic Rock\Devo - Oh, No! It's Devo\Devo - Oh, No! It's
Devo.jpg
I put this into the ImageURL of the image control. When I look at the
properties of the image from the displayed page the URL ends up being
Devo%2520-%2520Oh,%2520No!%2520It's%2520Devo.jpg.
I am very confused ( a normal thing ) but really need a push in the right
direction here.
Thanks
Lloyd Sheen
Steve C. Orr [MCSD, MVP, CSM, ASP Insider] - 07 Jun 2007 19:21 GMT
Here I've detailed all the steps you need to store and retrieve images in a
sql server database:
http://SteveOrr.net/articles/EasyUploads.aspx

Signature
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
>I have a list of JPG's which are found in a SQL Server database. When the
>page selects a certain piece of data it will refer to the file system
[quoted text clipped - 21 lines]
>
> Lloyd Sheen
Lloyd Sheen - 07 Jun 2007 19:35 GMT
> Here I've detailed all the steps you need to store and retrieve images in
> a sql server database:
[quoted text clipped - 26 lines]
>>
>> Lloyd Sheen
Steve,
Thanks for the quick reply. I guess my explain is not good. I have
only the filenames in the database. The database is used to speed access to
the info rather than using the filesystem.
When I get a filename of a jpg I want to display the jpg as part of an
aspx page. I have an image control and just want to set the ImageURL
property to get it to show.
All files are under a virtual directory under IIS 7.
Lloyd Sheen
Peter Bromberg [C# MVP] - 07 Jun 2007 20:45 GMT
string imgName = imageFromDatabaseRow["image"];
ImageControl.ImageUrl =ResolveUrl("images/"+imgName);
Peter

Signature
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
> > Here I've detailed all the steps you need to store and retrieve images in
> > a sql server database:
[quoted text clipped - 40 lines]
>
> Lloyd Sheen
Lloyd Sheen - 07 Jun 2007 21:39 GMT
> string imgName = imageFromDatabaseRow["image"];
> ImageControl.ImageUrl =ResolveUrl("images/"+imgName);
[quoted text clipped - 52 lines]
>>
>> Lloyd Sheen
Ok here is example:
From database I get the folder name and then pickup the filename using
System.IO. The code I am using is below and then followed by the watch
values during debugging:
Dim url As String =
d.GetImageURL(Me.ListOfArtists.SelectedItem.ToString,
Me.ListOfCDs.SelectedItem.ToString, Request)
Me.CDImage.ImageUrl = ResolveUrl(url)
url "D:\My Music\Best Of\Abba - The Complete
Singles Collection\Abba - The Complete Singles Collection.jpg" String
cdimage.ImageUrl "D:\My Music\Best Of\Abba - The Complete Singles
Collection\Abba - The Complete Singles Collection.jpg" String
There is no change to the url by using the ResolveURL so right now I am at a
loss. I am trying to get this to work both in Dev and for an ISS 7 hosted
site. Since I am on Vista and cannot get IIS 7 to talk to VS 2005 I need to
dev and then publish. The virtual directory that the files sit under does
not exist on the VS 2005 dev server so I am having problems resolving all of
this.
Thanks.
Lloyd Sheen
Peter Bromberg [C# MVP] - 07 Jun 2007 21:50 GMT
ok. Well, it really gets a lot easier when you create a virtual directory in
IIS that points to the images folder, wherever it may be. then the path will
always be "images/filename.ext".
Peter

Signature
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
> > string imgName = imageFromDatabaseRow["image"];
> > ImageControl.ImageUrl =ResolveUrl("images/"+imgName);
[quoted text clipped - 79 lines]
>
> Lloyd Sheen
Lloyd Sheen - 08 Jun 2007 15:29 GMT
> ok. Well, it really gets a lot easier when you create a virtual directory
> in
[quoted text clipped - 104 lines]
>>
>> Lloyd Sheen
Ok what I ended up doing is on the request I copy the jpg if it does not
already exist (they are not large) to a folder under my website. This in
combo with the ResolveURL gives the required result for both the dev and IIS
versions with no code change.
But this still does not answer my original question. How would I create a
URL which would point to a file which is no under my web site?
Thanks
Lloyd Sheen
Peter Bromberg [C# MVP] - 08 Jun 2007 15:37 GMT
to answer your unanswered question, a url to an image needs to be a valid
http-addressable url. It doesn't matter "where" that is, as long as it is a
web site where an <img src="http://www.wherever.com/images/yourimage.jpg" >
will work.
Peter

Signature
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
> > ok. Well, it really gets a lot easier when you create a virtual directory
> > in
[quoted text clipped - 115 lines]
> Thanks
> Lloyd Sheen
sloan - 10 Jun 2007 02:54 GMT
Writing your own IHttpHandler is the best way to achieve image retrieving
that performs well.
Find the NorthwindImageGrabber in this demo code by Jeff Prosise
http://www.wintellect.com/Downloads/Asynchronous%20ASP.NET.zip
and corresponding PictureGridView.aspx
>I have a list of JPG's which are found in a SQL Server database. When the
>page selects a certain piece of data it will refer to the file system
[quoted text clipped - 21 lines]
>
> Lloyd Sheen