June 08, 2011 05:00 PM

Create a Simple Task List Using ASP.NET, WCF, and jQuery, Part 1

Easily make an application that allows users to define, add, edit, delete, and filter tasks
Dev Pro
InstantDoc ID #129917
Downloads
129917_TaskList_Code.zip

Maintaining a task list (or a to-do list) is a common time management technique that helps us keep track of work and agenda items, along with their priority and status. No wonder Windows Task Manager is often an integral part of web and desktop calendaring applications. In this two-part article, we will build our own task-list application using jQuery, ASP.NET, and Windows Communication Foundation (WCF). Though simple, our task-list application will illustrate how jQuery can interact with server data through WCF services. We will also get to apply several jQuery concepts such as selectors, AJAX calls, and plug-ins.

Functional Requirements

First, let’s summarize our expectations for the task-list application that we are going to build:

  • Users should be able to define tasks. A task definition consists of title, description, priority (e.g., high, normal, low); status (e.g., pending, in-process, completed); and due date.
  • Users should be able to add, edit, and delete tasks.
  • Users should be able to filter tasks on the basis of priority and status.
  • Tasks that have a due date that has already passed should be highlighted when the application starts.
  • The application should talk with the server only during add, edit, and delete operations to keep post backs or page refreshes to a minimum.

We will use jQuery, ASP.NET 4.0, and SQL Server 2008 to develop the task-list application. The application will illustrate how to:

  • Use common jQuery selectors.
  • Use Microsoft's jQuery template plug-in to create a grid layout.
  • Deal with dates while communicating with WCF.
  • Make AJAX calls to WCF service through jQuery.
  • Create your own plug-in using jQuery.

Creating the Web Application

To begin, use Visual Studio to create a new ASP.NET website. Figure 1 shows the New Web Site dialog box in Visual Studio.

129917_Figure 01_0
Figure 1: Creating a new website in Visual Studio

Once the website is created, add a new folder named Scripts, and place the jQuery files in it, as Figure 2 illustrates.

129917_Figure 02_0

Figure 2: Placing jQuery script files

Note: For detailed instructions about downloading the jQuery library and the jQuery templates plug-in, see the ReadMe.txt file in the code download that accompanies this article.

All the data that the task-list application requires will be stored in a SQL Server database. To add a new SQL Server database to your website, right-click the App_Data folder and select Add New Item to open a dialog box, which Figure 3 shows.

129917_Figure 03_0
Figure 3: Adding a SQL Server database

Give the database a name, such as TaskListDb.mdf. Once the database is ready, create a new table named Tasks with the schema as shown in Figure 4.

129917_Figure 04_0
Figure 4: Tasks table schema

The Tasks table has six columns: TaskID, Title, Description, Priority, DueDate, and Status.

Creating a WCF Service to Perform Data Access

The data from the Tasks table needs to be accessed from the client side using jQuery code. Hence, we need a callable endpoint at the server end that can be consumed from the client. A WCF service can provide such an endpoint. We will use a WCF service for adding, updating, deleting, and retrieving data from the Tasks table. Later, we will call this WCF service from the jQuery code.





ARTICLE TOOLS


Comments
  • 10 months ago
    Jul 05, 2011

    Readme files is missing from the download!!!!

    It's almost a month since this article was posted...

    Any updates????

  • 10 months ago
    Jul 04, 2011

    So, where is the ReadMe.txt file?

  • ASPDotKen
    11 months ago
    Jun 17, 2011

    This is no Readme file in the download.

You must log on before posting a comment.

Are you a new visitor? Register Here