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

N

news.microsoft.com

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
 
F

fd123456

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,585
Members
45,080
Latest member
mikkipirss

Latest Threads

Top