Tuesday, March 13, 2012

Simple gallery

Hi,

What I've got yet: a default.aspx page with 9 image buttons (thumbnails) and 9 pages with a image larger than the thumbnails. The photopages react on the onclick event in the default page. Every thumbnail has his own onclick event and has his own photopage. This is a lot from the same and I like to have one default.aspx and one photo.aspx that programmatically load the different photo's. But i don't know where to start. Any ideas??

Thanks,

RoelHello, what you can do is have a database table, in which you list all the image paths that you have.
Then, in the default.aspx page, you can access that database, and get all the image paths and display them in the datalist control maybe by having 3 images per row or as many as you want. Inside the datalist you can use something as:


<itemtemplate>
<asp:HyperLink ID="viewImage" ImageUrl=<%# DataBinder.Eval ( Container.DataItem, "imagePath" ) %> NavigateUrl= <%# "finalyearViewer.aspx?id="+DataBinder.Eval ( Container.DataItem, "id" ) %> runat="server" Target="_self"></asp:HyperLink>
</itemtemplate>

Hope that will help you out.

regards.
There's 2 ways to do this - a quick way or a slow way.

The quick way would be to pass the image filename in a querystring to your photo.aspx page and then have that read the querystring and load up that image.

The slow way would be to create a database that stores pictures and information such as a picture caption, picture date, and image location (along with primary key of ID). You could then write a picture upload script that would save all this information to the database.

On your default.aspx page you have your image button urls pass the ID to the photo.aspx page. In fact, default.aspx could do a database read and display each thumbnail (one thumbnail for each record in the database) so then you'd never have to manually update the HTML on the page. Photo.aspx would do a database read to get the image location, image caption, author, picture date, etc.. and display the image on the screen.

Method 2 is actually pretty simple process it just takes a bit of work to get it done (if you go with the admin part to add/delete/edit pics). Feel free to ask for help if you get stuck, I've done stuff like this quite a few times.
Method n° 3 would be the lazy one I guess.

Take a look atnGallery.

Maybe some overkill but it's free.

Grz, Kris.

0 comments:

Post a Comment