September 2008 Entries

In this series of blog entries, I build an entire MVC Forums application from start to finish. In this entry, I create the user interface for the Forums application by taking advantage of ASP.NET AJAX client templates. I build the entire user interface for the Forums application with a single view and perform all updates to the view with Ajax calls. A page request is just an excuse for a bad user experience. We are conditioned to expect our web pages to freeze whenever we interact with a website. For example, each and every time we submit a form, we expect...

Posted Monday, September 22, 2008 7:36 AM

(ASP.NET MVC + Silverlight + Flip Video) is a wonderful combination! In this blog entry, I continue building the Family Video Website. I integrate a new Silverlight video player, demonstrate how to upload Flip videos, and add paging. This blog entry is part of a series of entries on using ASP.NET MVC to build an entire Family Video Website from scratch. Before reading this entry, you might want to read the previous three entries: Family Video Website #1 – Upload the Videos – In this entry, I create an MVC controller that accepts large file uploads. Family Video Website #2 –Add the Database...

Posted Thursday, September 18, 2008 7:30 PM

In this tip, I demonstrate how you can create a custom HTML Helper that you can use to generate a user interface for paging through a set of database records. I build on the work of Troy Goode and Martijn Boland. I also demonstrate how you can build unit tests for HTML Helpers by faking the HtmlHelper class. This week, I discovered that I desperately needed a way of paging through the database records in two of the sample MVC applications that I am building. I needed a clean, flexible, and testable way to generate the user interface for paging through...

Posted Thursday, September 18, 2008 7:25 AM

In this series of blog posts, I build an entire ASP.NET MVC Forums application from start to finish. In this post, I explain how to test and implement authentication and authorization for the Forums application. Before you read this blog post, you should read the previous posts in this series: ASP.NET MVC Application Building: Forums #1 – Create the Perfect Application – In this first entry, I explain the overall goals of the ASP.NET MVC Forums application. I emphasize the importance of Software Design Principles and justify my choice to use test-driven development. ASP.NET MVC Application Building: Forums #2 – Create the First...

Posted Friday, September 12, 2008 4:22 PM

In this tip, I demonstrate how to take advantage of the validators from the System.ComponentModel.DataAnnotations namespace in an MVC application. You can take advantage of these validators to validate form data before submitting the form data into a database. In my previous tip, I explained how you can take advantage of the validators included with the Microsoft Enterprise Library Validation Application Block to validate an entity before submitting the entity to a database. The Validation Application Block supplies you with a very rich set of validators that support advanced validation scenarios. You can read about using the Validation Application Block in...

Posted Wednesday, September 10, 2008 11:20 PM

In this tip, I demonstrate how you can use the Microsoft Enterprise Validation Application Block within an MVC application to perform both basic and advanced form validation. The Validation Application Block supports a rich set of validators that you can begin using in an ASP.NET MVC application. In this tip, I show how you can use the Microsoft Validation Application Block to perform form validation within an ASP.NET MVC application. Using the Validation Application Block was surprisingly easy. You can download and start using the Validation Application Block in minutes. The Validation Application Block uses a model-driven approach to validation. You specify...

Posted Wednesday, September 10, 2008 2:50 AM

I received a lot of feedback on my last blog entry on implementing server-side form validation for the MVC Forums application. Thank you everyone for the feedback! In my previous blog entry, I described how you can perform validation in an MVC application by taking advantage of custom validation attributes. By decorating your model with attributes, such as the RequiredValidator and RegularExpressionValidator attributes, you can enforce validation rules and display custom validation error messages. In order to perform more complex validation, I suggested using a CustomValidator that could be applied to the entity class. The CustomValidator class points to another class...

Posted Tuesday, September 09, 2008 8:17 AM

In this series of blog entries, I build an entire ASP.NET MVC forums application from start to finish. In this blog entry, I add server-side form validation to the forums application. This post has been updated. Please read the updated post here: Forums #4 1/2 - Validation Revisited Before reading this blog entry, you should read the previous three blog entries in this series: ASP.NET MVC Application Building: Forums #1 – Create the Perfect Application – In this first entry, I explain the overall goals of the ASP.NET MVC Forums application. I emphasize the importance of Software Design Principles and justify my...

Posted Monday, September 08, 2008 10:22 AM

In this tip, I demonstrate three methods of creating cascading drop down lists in an MVC application. First, I demonstrate how to write JavaScript code to update one dropdown list when another dropdown list changes. Next, I show you how you can retrieve the data for the dropdown lists from either a controller action or a web service. A reader of this blog emailed me recently and asked how he could create cascading dropdown lists in an MVC application. Why would you want to create cascading dropdown lists? Imagine that you want a user to select a car make and model....

Posted Sunday, September 07, 2008 12:56 AM

In this series of blog entries, I build an entire ASP.NET MVC forums application from start to finish. In this blog entry, I add the functionality to the Forums application that enables users to post new messages and replies. Before reading this blog entry, you should read the previous two blog entries in this series: ASP.NET MVC Application Building: Forums #1 – Create the Perfect Application – In this first entry, I explain the overall goals of the ASP.NET MVC Forums application. I emphasize the importance of Software Design Principles and justify my choice to use test-driven development. ASP.NET MVC Application Building: Forums...

Posted Saturday, September 06, 2008 12:44 AM

In this series of blog entries, I build an entire ASP.NET MVC Forums application from scratch. In this blog entry, I create my first unit test for the Forums application and implement the code necessary to pass the test. Before reading this blog entry, you might want to read the first entry in this series: ASP.NET MVC Application Building: Forums #1 – Create the Perfect Application – Describes the goals of the ASP.NET MVC Forums application. Create the ASP.NET MVC Application Let me start by creating a new ASP.NET MVC application. Launch Visual Studio 2008 and select the menu option File, New Project. Select...

Posted Friday, September 05, 2008 5:41 PM

In this series of blog entries, I build an entire ASP.NET MVC Forums application from start to finish. The goal is to discover and promote best-practices for building applications with the ASP.NET MVC framework. In this first entry, I discuss the overall goals for the forums application. I discuss the importance of avoiding code smells and how software design principles and patterns can help you write code that is resilient to future change. I also justify my choice to use test-driven development while building the Forums application. What is Good Software? I don’t want to build just any forums application. The goal...

Posted Friday, September 05, 2008 4:41 PM

In this series of blog entries, I build an entire ASP.NET MVC application from start to finish. In this entry, I integrate the Silverlight Media Player into the Family Videos MVC application so I can play videos. Before reading this blog entry, you might want to first read the previous two entries: Family Video Website #1 – Upload the Videos – In this entry, I create an MVC controller that accepts large file uploads. Family Video Website #2 –Add the Database – In this entry, I added a database so that I could associate additional information, such as a title and description, with...

Posted Thursday, September 04, 2008 2:56 AM