Wednesday, February 6, 2008

ASP.NET Futures in Visual Studio 2008

After recently installing VS2008 I decided that it was time to start diving deeper into ASP.NET AJAX.

One of the design options for a project I am working on is to use drag-and-drop to perform various tasks. This article describes how to implement a simple drag and drop behaviour.

What the article doesn't describe is how to get the Visual Studio environment set up to enable these behaviours.

I knew from previous visits to http://asp.net/ajax/ that this part of the ASP.NET AJAX Framework has been separated into an ASP.NET Futures CTP which was available for download from the above website. However, the link no longer exists on the home or download pages. Quickstarts are available although they are not easy to find.

The ASP.NET AJAX site now links to the Microsoft ASP.NET 3.5 Extensions Preview. Although this package does include certain updates to the AJAX framework (such as History support) it does not include the features from the ASP.NET Futures CTP.

I tried to find a recent statement on the future of the Futures CTP but didn't manage to find one. The CTP is still available for download, and although it is labelled as the July 2007 CTP it was in fact updated in December to work with VS2008 RTM. I guess that this is a sign that it is still being worked on.

Anyway, back to getting the drag and drop sample to work. The following steps are required to get Jeff Prosise's sample to work in VS2008 and, although I haven't tried it, VS2005.

  1. Download the ASP.NET Futures CTP (July 2007). If you downloaded it prior to December then download it again so that you get a copy that works with VS2008 RTM.
  2. Create a new ASP.NET Futures Web Application project. If you have an existing project then add a reference to Microsoft.Web.Preview.dll.
  3. Create a dragDropTest.js file that contains Jeff's sample code. You will also need to add the following line to the top of the file:

    Type.registerNamespace('Custom.UI');

    Add the following line to the bottom of the file:

    if(typeof(Sys) !== 'undefined') { Sys.Application.notifyScriptLoaded(); }

  4. Add a ScriptManager component to your aspx page if you haven't already. Add the following script references in this order:

    <Scripts>
    <asp:ScriptReference Name="PreviewScript.js" Assembly="Microsoft.Web.Preview" />
    <asp:ScriptReference Name="PreviewDragDrop.js" Assembly="Microsoft.Web.Preview" />
    <asp:ScriptReference Path="~/DragDropTest.js" />
    </Scripts>
  5. Run the project, and start dragging and dropping!