Photo/File Dir

Summary:

This controls analyzes a path on the server. It then shows the directories in that path and allows the user to choose a directory to view. Then, it lists (optionally) the contents (files) of the chosen directory and allows the user to choose a file. That's all (of course, the chosen dir/file can be retrieved).

Click here for an image example

...More:

When the control is first displayed, there is a box including the main directories of the chosen path. There is also a link to view the chosen path. Each directory is accompanied by a directory icon. The user is allowed to choose a directory. Then, another box pops out showing the directories of the chosen directory and two links. The first link is used to view the chosen directory and the other to view the parent directory (the user is not allowed to go further above the chosen path). The user is then allowed to choose a sub-directory. When clicked the same box refreshes for that directory.
When the link "View directory" is clicked (included in each box), another box pops up (optionally). It shows the files of the directory (with icons according to the extension of each file). The box can be refreshed when the link is clicked again (for another directory for example). Then the user is allowed to click a file.

Each action is captured by events and public properties for you to manipulate. [For example, I used it for a photos thumbnail browser].

Properties & Specifications:

The control inherits from the Control class.

PropertyAssignment TypeDefault ValueComments
rPathString"\"The relative path of the path to be browsed.
TablesWidthString"48%"The width of the boxes (can be integer or string such as "50%").
TablesStyleClassString"defaulttext"The string that is put in the "class" tag of each box. (usually for fontsizes and such).
ImgsPathString"/Images/Menu/"The path where the icons are stored (for the file and the dir icons).
MaxSubDirsInteger50The maximum number of sub-directories that can exist to show.
MaxFilesInteger300The maximum number of files that can exist to show.
UseFileViewerBooleanTrueWhether the files are showed when a directory is selected to view.
DirDisplayedStringThe virtual path of the directory that is shown.
DirToViewStringThe virtual path of the directory for which the View Link is clicked.
FileToViewStringThe virtual path of the file that was selected.

MethodComments
LoadNewDir(Object, EventArgs.empty)Load up a new directory path. The path is taken from the Object's CommandArgument (so the object could be a LinkButton instance).

EventComments
OnDirChangeWhen the directory shown is changed. DirDisplayed is also changed.
OnViewClickedWhen the View link is clicked. The DirToView is also changed
OnFileClickedWhen a file is clicked. The FileToView is also changed
Icons
The icons and images shown must be found in the directory specified by the ImgsPath property. In the FileViewer the icons next to each icon are in accordance to each file's extension. To have a different icon for each extension, put your .gif file in the images path directory like this: Filejpg.gif for the files with .jpg extension. Or Filedoc.gif for the files with .doc extension. If an icon for the extension of a file doesn't exist, the icon File.gif is shown.

Usage:

You can either use the control through script by referring to TPControls.GalleryDir (according to the install instructions), or either through placing a control instance on an .aspx page like this:

<TP:GalleryDir runat="server" [rPath="Path String"] [TablesWidth=Width String] [TablesStyleClass=CSS class string] [ImgsPath=Path String] [MaxSubDirs=Integer] [MaxFiles=Integer] [UseFileViewer=Boolean] [OnDirChange=Sub for event] [OnViewClicked=Sub for event] [OnFileClicked=Sub for event] > </TP:GalleryDir>
The brackets [ ] are used to show the optional. Italics are used to show the text you need to type according to your preferences.

e.g. <TP:GalleryDir runat="server" rPath="\Images\Photos" ID="GalleryDirs" TablesWidth="100%" OnFileClicked="RefreshThumbnail"> </TP:GalleryDir>

Comments:

The word Photos or the word GalleryDir in the name of the control hasn't much relation to its function. The control can successfully list a dir with files as well as images. It was firstly intended only for images, that's why.

Also, certain asp.net errors have been noted with this control. Anyone interested to fix this bug is welcome (because it works well on my PC).