Click here to Skip to main content
15,906,341 members
Articles / Web Development / ASP.NET
Article

ASP.NET PhotoBook

Rate me:
Please Sign up or sign in to vote.
3.50/5 (9 votes)
17 Oct 20042 min read 76K   4.6K   62   1
A simple photobook viewer.

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:

C#
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:

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

Putting the controls onto the webpage goes like this:

HTML
<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


Written By
Web Developer
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralThank u very much Pin
dongxiang11-Jun-07 21:20
dongxiang11-Jun-07 21:20 
Smile | :) Smile | :) Smile | :) Smile | :) Smile | :) Smile | :) this is usefully code for me ,thank u very much

doney

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.