Krystalware
SlickUpload | Documentation | Demos | Purchase | Free Stuff | Forums | Blog | Testimonials | Company | Contact

Up until SlickUpload 5.5, the ASP.NET MVC examples demonstrated calling the SlickUpload.GetUploadStatus() method in your action method to get the current upload status. This isn't the optimal way to get access to upload status and uploaded files in your action method -- it violates the idea of separation of concerns that MVC is built upon.

Fortunately, the fix is easy -- create and register a custom ModelBinder that maps the UploadStatus into a parameter for your action method. The model binder is simple:

using System;
using System.Web;
using System.Web.Mvc;

using Krystalware.SlickUpload;
using Krystalware.SlickUpload.Controls;
using Krystalware.SlickUpload.Status;

public class UploadStatusModelBinder : IModelBinder
{
    public static void Register(ModelBinderDictionary modelBinders)
    {
        if (!modelBinders.ContainsKey(typeof(UploadStatus)))
            modelBinders.Add(typeof(UploadStatus), new UploadStatusModelBinder());
    }

    public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
    {
        UploadStatus status = HttpUploadModule.GetUploadStatus() ?? UploadConnector.GetUploadStatus();

        return status;
    }
}

The Register method manages registering this class in ASP.NET MVC's model binder lookup. Call it from your Application_Start, the same place where you register routes. Something like:

protected void Application_Start()
{
    RegisterRoutes(RouteTable.Routes);

    UploadStatusModelBinder.Register(ModelBinders.Binders);
}

The BindModel method does the actual binding. The logic pulls the UploadStatus for the current context, and if that isn't available checks to see if this is a SlickUpload based after upload postback and returns the UploadStatus for that. If it's neither, the parameter will recieve null.

So, your MVC controller action method changes from this:

public ActionResult UploadResult()
{
    UploadStatus status = SlickUpload.GetUploadStatus();

    // controller logic

    return View(status);
}

To this:

public ActionResult UploadResult(UploadStatus status)
{
    // controller logic

    return View(status);
}

We've recently released SlickUpload 5.5. This was originally going to be v. 5.4.3, but it ended up getting some larger improvements, primarily around ASP.NET AJAX support. The ASP.NET AJAX support has been completely rewritten in version 5.5, with much improved support for advanced scenarios. We have also set up a comprehensive test suite to cover the ASP.NET AJAX functionality to ensure that it handles every edge case and continues to do so.

Several more things made it into this release:

  • Refactoring of the FileList. The file related events and methods were removed to reduce confusion and code surface area -- you can do anything you once did with this functionality by using the identical events and methods on the FileSelector.
  • Added the OnFileAdding event. This allows you to perform validation on a file before it is selected before it is added to a list. If your handler returns false, the file won't be added.

There are also a slew of small fixes and enhancements, including:

  • Added support for setting progress url
  • Fixed keyboard accessibility on downlevel template

SlickUpload 5.2 was just released. This version adds support for skinning the actual html file selector using any html you specify. The skinning works in IE 6+, FF, Chrome, and Safari 2+. Any other browsers will gracefully use the original downlevel behavor. To see this in action, look at any of the SlickUpload samples.

Breaking change: The SlickUpload.SelectorHtmlTemplate property is renamed to DownlevelSelectorTemplate, and the FileSelector.HtmlTemplate property is renamed to DownlevelTemplate.

To implement this in your application, simply add a UplevelSelectorTemplate definition in your page and add html to define what the selector will look like. For example, to use a button with the text "Add Files", your uplevel selector template would look like the following:

<kw:SlickUpload ...>
    ...
    <UplevelSelectorTemplate>
        <input type="button" value="Add Files" />
    </UplevelSelectorTemplate>
    ...

You're not limited to just a button type -- you can use any text or images in this template.

As always, the latest version is available on the SlickUpload download page.

We released SlickUpload 5.1.1 yesterday. It adds several great new features that weren't implemented in 5.0, including internationalization support, SQL status manager optimizations (used for clustered environments), additional templating support, and a cancel confirmation message that appears when users navigate the browser during an upload. This version also adds MVC support, fixes several little bugs with the 5.0 release, and includes 5 more samples that demonstrate advanced functionality enabled by SlickUpload 5.

New Samples

  • ASP.NET MVC example showing how the SlickUpload control can be used within an ASP.NET MVC application
  • ASP.NET AJAX example demonstrating the SlickUpload control on a page with an UpdatePanel control
  • Progress templating and file list templating sample. This shows how to use images for the progress bar, template the file list with css, and display file type icons for files as they are selected.
  • Modal progress sample. This sample demonstrates how to put the progress display in a modal popup on page.
  • Localization sample. Example of localizing the SlickUpload control using ASP.NET's built in localization support.

The new download is available, as always, on the SlickUpload download page.

April is Amazon Web Service's Amazon Simple Storage Service (Amazon S3)'s third anniversary. In honor of this, Amazon is offering S3 data transfer in for $0.03 per GB (vs the normal $0.10) from April to June. This is a welcome announcement for those of us using S3 storage for files.

Check out our SlickUpload with Amazon S3 example for more details on using SlickUpload to upload to S3.