468,103 Members | 1,311 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,103 developers. It's quick & easy.

Create an Image Gallery with FILES web directory and names of files in SQL server

Hello and first of all thank you for your time.

I am currently developing an ASP.net web page, which has data stored in SQL
Server. It is a web page for a State Agent and my problem is:

I need to create an image gallery (with some kind of slide Next and Previous
picture) of the flat you are interested to see.

The pictures are stored on a directory of the web.

The names of the pictures are stored, also, on a table in SQL which is
FlatPhotos, and of course I have the fields PhotoID, FlatID, on
one-to-multiple basis, as there are around 10 or 14 photos for each flat.

I have already designed the page for the one-only-flat that you are
interested to see, and everything is working fine, except for the picture
gallery.

I have been working and trying to search for info on the web for more than 8
hours now, an I decided to contact you.

The final design is like this

<=Previous Button
Picture 1
Picture 2
Picture 3
Picture 4
Picture 5
Next button =>




Main picture (or the picture you click on in a bigger size)




Text info of the flat


Can you help me with this, please?

Thanks again and sorry for the inconvenience.

Albert Lens

WIN SOLUTIONS SL
Nov 19 '05 #1
1 1705
Hi Albert,

I would use the query string to discriminate between pictures.

Say your page is called "FlatCheck". Upon Page_Load, check for the
number of pictures that exist for that particular flat. Say, there are
8 of them.

Create (in a loop) 8 HyperLinks, each being directed to that same
page, with "?Pic=" + the number at the end, and add them to a
placeholder on your page. Example :

for (int n = 0; n < NumberOfPics; n++)
{
HyperLink hl = new Hyperlink;
hl.Text = "Picture " + n.ToString();
hl.NavigateUrl = "FlatCheck.aspx?Pic=" + n.ToString();
myPlaceHolder.Controls.Add(hl);
}

Create a variable to hold the number of the picture to be shown :

int DesiredPic = 0;

Next, check the Query string :

string s = Request.QueryString["Pic"]
if ( (s != null) & (s.Length>0) )
DesiredPic = Convert.ToInt32(s); // you should trap errors and check
for consistency here

Then, get your picture name from the db (pseudo code here, as I don't
know how your db is layed out) :

string PicPath = new myDB().GetPicturePath(FlatNumber,DesiredPic);

Finally, assign the path you just got to the Image on the page:

myImage.ImageURL = Server.MapPath("") + PicPath;

And you should be good to go.

To open the picture in a separate window, you must use Javascript. If
you want that window to be the exact size of the picture, you have to
know the size of the picture beforehand (either load if first - time
and processor costly - or have it's size written in the db - not
always possible if you don't own the db). Anyway, there are lots of
scripts out there to do this. Look for "javascript picture
window.open" in Google.

HTH,

Michel
"news.microsoft.com" <co*******@winsolutions.es> wrote in message news:<ub**************@TK2MSFTNGP14.phx.gbl>...
Hello and first of all thank you for your time.

I am currently developing an ASP.net web page, which has data stored in SQL
Server. It is a web page for a State Agent and my problem is:

I need to create an image gallery (with some kind of slide Next and Previous
picture) of the flat you are interested to see.

The pictures are stored on a directory of the web.

The names of the pictures are stored, also, on a table in SQL which is
FlatPhotos, and of course I have the fields PhotoID, FlatID, on
one-to-multiple basis, as there are around 10 or 14 photos for each flat.

I have already designed the page for the one-only-flat that you are
interested to see, and everything is working fine, except for the picture
gallery.

I have been working and trying to search for info on the web for more than 8
hours now, an I decided to contact you.

The final design is like this

<=Previous Button
Picture 1
Picture 2
Picture 3
Picture 4
Picture 5
Next button =>




Main picture (or the picture you click on in a bigger size)




Text info of the flat


Can you help me with this, please?

Thanks again and sorry for the inconvenience.

Albert Lens

WIN SOLUTIONS SL

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Oliver | last post: by
9 posts views Thread by DaRemedy | last post: by
13 posts views Thread by Viken Karaguesian | last post: by
25 posts views Thread by Gilles Ganault | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.