Building a Photo Tagging Application using ASP.NET 2.0, LINQ, and Atlas
page 6 of 9
by Scott Guthrie
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 38528/ 135

Step 5: Browsing Photos By Tag

The next page I added to the site was one named “PhotoListing.aspx”.  The tag-cloud control used above creates a hyperlink for each tag that links to this page and passes the tag name as an argument to it when you click a tag.

The PhotoListing.aspx page I created is based on the Site.Master template above and uses a templated DataList control to output the pictures in a two-column layout:

Listing 9

<asp:Content ID="C1" ContentPlaceHolderID="MainContent" Runat="server">
    <div class="photolisting">
        <asp:DataList ID="PhotoList" RepeatColumns="2" runat="server">        
                <div class="photo">
                    <div class="photoframe">
                        <a href='PhotoDetail.aspx?photoid=<%# Eval("PhotoId") %>'>
                            <img src='<%# Eval("Thumbnail") %>' />      
                    <span class="description">
                        <%# Eval("Description") %>

Below is the entire code-behind for the page:

Listing 10

using System;
using System.Query;
using PhotoAlbum;
public partial class PhotoListing: System.Web.UI.Page
  void PopulatePhotoList(string tagName)
    PhotoDB photoDb = new PhotoDB();
    if (tagName == null)
      PhotoList.DataSource = photoDb.Photos;
      PhotoList.DataSource = from photo in photoDb.Photos where photo.Tags.Any
        (t =  > t.Name == tagName)select photo;
  protected void Page_Load(object sender, EventArgs e)

When a user clicks on the “Cats” tag in the tag-cloud, they’ll then see this list of photos rendered:

Figure 7

View Entire Article

User Comments

Title: dfds   
Name: vvxc
Date: 2012-11-02 8:00:17 AM
Title: Dear   
Name: Bilal khan
Date: 2012-08-07 1:13:37 PM
Plz send this article to my email address

thanks in advance
Title: th   
Name: Janaa
Date: 2009-09-28 9:09:50 AM
Thats seems to be very useful. I will try to use it on my site thx.

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-05-28 5:52:20 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search