Click here to Skip to main content
5,790,650 members and growing! (21,483 online)
Email Password   helpLost your password?
Web Development » Applications & Tools » Applications     Intermediate

ASP.NET PhotoBook

By WoutL

A simple photobook viewer.
C#, Windows, .NET, Visual Studio, ASP.NET, Dev

Posted: 17 Oct 2004
Updated: 17 Oct 2004
Views: 51,467
Bookmarked: 44 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
8 votes for this Article.
Popularity: 3.14 Rating: 3.48 out of 5
2 votes, 25.0%
1
0 votes, 0.0%
2
1 vote, 12.5%
3
1 vote, 12.5%
4
4 votes, 50.0%
5

Sample Image - photobook.jpg

Introduction

This ASP.NET application shows thumbnails and photos. It does nothing more and nothing less.

Background

Every year we go on holiday with a couple of friends. After each holiday, we want to share our digital photos. We tried mailing a CD around, but we wanted a better solution. So I volunteered to make a website where everyone can download the photos they want.

I wanted the application to be as simple as possible. Just a webpage with some photos. And no database. I ended up with one webpage with two custom controls.

Using the code

The webpage itself is very simple. It is just plain HTML (with some ASP.NET of course). All formatting of the page is done in CSS.

Also, the code behind the page is simple:

public class _default : System.Web.UI.Page
{
    protected System.Web.UI.WebControls.Panel pnlPhotos;
    protected Photobook.Photos Photos1;
    protected BookTree BookTree1;
    
    private void Page_Load(object sender, System.EventArgs e)
    {
        Photos1.Holiday = Request.QueryString["Holiday"];
        Photos1.By = Request.QueryString["By"]; }
    }

In my humble opinion, just the two custom controls need some explanation.

BookTree

The BookTree control writes a simple tree to the webpage using <UL> and <LI> elements. The tree is the directory structure under the Photobooks directory. This last directory is a directory under the webpage. The structure is like this:

[Photobooks]
    [HolidayName]
        [Photographer]
            Thumbnails
        [Photographer]
            Thumbnails
    [HolidayName]
        [Photographer]
            Thumbnails
        [Photographer]
            Thumbnails

The photos of a particular photographer are placed in the [Photographer] directories. In the Thumbnails directory are thumbnails of the photos with the same name as the photo in the [Photographer] directory.

In the webpage, the [Photographer] directories will be displayed as links. The HREF they point to is the same page (default.aspx in my case), but with two extra options: Holiday and by. There values are [HolidayName] and [Photographer].

Photos

The second control is called photos. This control just shows the images of the photos (JPGs) in a directory. If thumbnails are available in the Thumbnails they will be displayed instead of the photos themselves.

If a user clicks on one of the thumbnails, the corresponding picture will be displayed in its original size, so the user can save it to his own hard disk.

Using the controls

The controls are in the same project as the webpage. The assembly still needs an extra registration in the webpage however. This to register the TagPrefix:

<%@ Register TagPrefix="cc1" Namespace="Photobook" Assembly="Photobook" %>

Putting the controls onto the webpage goes like this:

<cc1:booktree id="BookTree1" runat="server" />
<cc1:photos id="Photos1" runat="server"  />

If you want to have the controls in the Toolbox, you can just register it. Visual Studio will put an extra reference to the DLL under References. You should delete this extra reference.

Conclusion

Photobook is a very simple photo book viewer with lots of limitations. The use of the application is very simple however, and that was my intention.

This is my first article on CodeProject. I don't know if I should explain the code some more, but I thought it was not necessary in this case.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

WoutL



Occupation: Web Developer
Location: Netherlands Netherlands

Other popular Applications & Tools articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 1 of 1 (Total in Forum: 1) (Refresh)FirstPrevNext
GeneralThank u very muchmemberdongxiang22:20 11 Jun '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 17 Oct 2004
Editor: Smitha Vijayan
Copyright 2004 by WoutL
Everything else Copyright © CodeProject, 1999-2009
Web16 | Advertise on the Code Project