Click here to Skip to main content
13,763,800 members
Click here to Skip to main content


267 bookmarked
Posted 12 Sep 2002
Licenced Ms-RL

An ASP.NET thumbnail solution

An article describing a set of ASP.NET tools for generation of thumbnails and thumbnail views.
<%@ Page Language="C#" Trace="false" %>
<%@ Register TagPrefix="PhilipSoft" TagName="ThumbList" Src="ThumbList.ascx" %>
<%@ import Namespace="System.Configuration" %>
<script runat="server">

    int width,height;
    protected void Page_Load(Object sender, EventArgs e)
      String path,filter;
      if(!IsPostBack) {
       // create thumbnail-size combo data
       ArrayList arSizes = new ArrayList();
       for(int i=50; i<=500; i+=50)
       // create columns combo data
       ArrayList arCols = new ArrayList();
       for(int i=1; i<=10; i++)
       // initial properties
       cbThumbSize.SelectedIndex=3; cbColumns.SelectedIndex=3;
       chkSaveThumbs.Checked = (ConfigurationSettings.AppSettings["DefaultSaveThumbnails"]=="true");
       txtPath.Text = Request.ApplicationPath.TrimEnd('/')+"/images/";
       txtFilter.Text = ConfigurationSettings.AppSettings["DefaultFilter"];
       if(txtFilter.Text=="") txtFilter.Text = "*.*";
       chkStretch.Checked = (ConfigurationSettings.AppSettings["DefaultAllowStretch"]=="true");
       int pagesize; try {
         pagesize = int.Parse(ConfigurationSettings.AppSettings["DefaultPageSize"]);
       } catch(ArgumentNullException ex) { pagesize=10; }
       txtPagesize.Text = pagesize.ToString();
       chkUseCOMobj.Checked = (ConfigurationSettings.AppSettings["EnableThumbnailCOMobject"]=="true");
      } // if not postback
      String sSize = cbThumbSize.SelectedItem.Text;
      int pos = sSize.IndexOf('x');
      width = int.Parse(sSize.Substring(0,pos));
      height = int.Parse(sSize.Substring(pos+1));
      // set properties of thumbnail control
      ThumbList1.SaveThumbnails = chkSaveThumbs.Checked;
      ThumbList1.Width = width;
      ThumbList1.Height = height;
      ThumbList1.HeaderTitle =
       "<h3>Thumbnail images of directory " +  ThumbList1.VPath + "</h3>";
      ThumbList1.Columns = int.Parse(cbColumns.SelectedItem.Text);
      ThumbList1.ShowFilenames = chkShowFiles.Checked;
      ThumbList1.Sort = chkSort.Checked;
      ThumbList1.AllowPaging = chkPaging.Checked;
      ThumbList1.PageSize = int.Parse(txtPagesize.Text);
      //ThumbList1.HideNavBar = true; ThumbList1.CurPage=1; // test
      ThumbList1.AllowStretch = chkStretch.Checked;
      ThumbList1.UseCOMobj = chkUseCOMobj.Checked;
      ThumbList1.Bevel = chkBevel.Checked;
      ThumbList1.ItemBackColor = System.Drawing.Color.White;
      // new properties
      ThumbList1.ShowComments = chkShowComments.Checked;
      ThumbList1.AllowEdit = chkAllowEdit.Checked;
    } //page_load
    void chkPaging_CheckedChanged(Object sender, EventArgs e) {
      txtPagesize.Enabled = chkPaging.Checked;

    <title>PhilipSoft Thumbnail control test page</title>
<body style="FONT: 9pt verdana">
    <form runat="server">
        <h1>.NET ThumbList control test page 
            <br />
            Path:<asp:TextBox id="txtPath" runat="server" Width="251px" BackColor="Linen"></asp:TextBox>
            &nbsp; Filter:<asp:TextBox id="txtFilter" runat="server" Width="93px" BackColor="Linen"></asp:TextBox>
            <br />
            <br />
            Select thumbnail size: 
            <asp:DropDownList id="cbThumbSize" runat="server" BackColor="Linen"></asp:DropDownList>
            &nbsp;&nbsp; Columns: 
            <asp:DropDownList id="cbColumns" runat="server" BackColor="Linen"></asp:DropDownList>
            <asp:CheckBox id="chkSaveThumbs" runat="server" Text="Save thumbnails"></asp:CheckBox>
            <asp:CheckBox id="chkShowFiles" runat="server" Text="Show filenames" AutoPostBack="True"></asp:CheckBox>
            &nbsp;&nbsp;<asp:CheckBox id="chkSort" runat="server" Text="Sort" AutoPostBack="True"></asp:CheckBox>
            <asp:CheckBox id="chkPaging" runat="server" Text="Allow paging" AutoPostBack="True" Checked="True" OnCheckedChanged="chkPaging_CheckedChanged"></asp:CheckBox>
            &nbsp;&nbsp;&nbsp; Pagesize: 
            <asp:TextBox id="txtPagesize" runat="server" Width="37px" BackColor="Linen">3</asp:TextBox>
            <asp:CheckBox id="chkStretch" runat="server" Text="Stretch thumbnails" AutoPostBack="True"></asp:CheckBox>
            <asp:CheckBox id="chkBevel" runat="server" Text="Beveled" AutoPostBack="True"></asp:CheckBox>
            <asp:CheckBox id="chkUseCOMobj" runat="server" Text="Use COM object" AutoPostBack="True"></asp:CheckBox>
            <asp:CheckBox id="chkShowComments" runat="server" Text="Show Comments" Checked="True" AutoPostBack="True"></asp:CheckBox>
            <asp:CheckBox id="chkAllowEdit" runat="server" Text="Allow editing"  Checked="True" AutoPostBack="True"></asp:CheckBox>
            <asp:Button id="cmdShow" runat="server" Width="156px" Text="Regenerate thumbnails"></asp:Button>
        <br />
        &nbsp;&nbsp;<PhilipSoft:ThumbList id="ThumbList1" runat="server"></PhilipSoft:ThumbList>
        <br />

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under Microsoft Reciprocal License


About the Author

Philipos Sakellaropoulos
Web Developer Forthnet
Greece Greece
Software developer and Microsoft Trainer, Athens, Greece (MCT,, MCSE 2003, MCDBA 2000,MCTS, MCITP, MCIPD).

You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06-2016 | 2.8.181113.4 | Last Updated 11 Dec 2002
Article Copyright 2002 by Philipos Sakellaropoulos
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid