Try Now

Document Control

by Gabe Sumner
Publication date:
Sep 1, 2009, 08:00 AM


  • Sitefinity 3.5

Price: $ 0

The Problem

I have a Corporate Intranet that I'm redesigning with Sitefinity that is jam packed with PDFs, Word Documents, PowerPoint presentations, Excel files, etc.   We're talking hundreds & hundreds of documents.  I want these documents to be managed by normal users.  Based on past experience I believe strongly that normal users are incapable of dealing with file management.  Which means giving users a folder to upload stuff into and then trusting them to set their links correctly will end very poorly.

I also want the documents to be organized within the native Sitefinity"Site Map". This Site Map is elegant and makes the organization of the web site self evident.  Which means I don't want to create a Sitefinity module.  Doing this would separate the organization of these documents from the native Site Map.

The Solution

I created a new Sitefinity control called "Document".  You can drag & drop this control onto any Sitefinity page.  Once placed, you can click Edit and be presented with a Custom Control Designer. This Control Designer will let you upload a file.  This file could be anything (a PDF, a Word document, an Excel file, a JPEG, etc).

Once uploaded the Control Designer handles saving the file to the website and creates a unique file name. The file name & file location get saved as properties of the "Document" control.

As long as you are in "Page Edit" mode this Document control doesn't really do anything except give you a chance to upload a file.  If you access the page for real, however, the control swings into action and redirects to the uploaded file.

Check out this link to see this Document control in action.

Before you click, hover your mouse over the link and look at the URL.That is an actual Sitefinity page.  Once you click the page the Document control will do a Response.Redirect() to the actual document file.

This control lets users upload documents without doing any file management.  The control also lets the documents be organized within the native Sitefinity "Site Map".  You can even make use of the"History" feature of Sitefinity with this control.  Old files never get removed, rather newer files just get a new file name and anew reference.  I even altered my "Links" control so that pages with a "Document" control open in a new window.

The unique file names are based on system ticks.  I'm also storing files in subdirectories so that the file index doesn't become too large.