TDD: Assets

Please see my other Test Driven Development articles. Leveraging overloaded Assert() methods to enhance test methods. Continuing from my TDD: Mocking with Dummy objects article, I wanted to illustrate some examples of other Assert() methods available for use to enhance testing results. As illustrated in my last example, you may just utilize the traditional Assert.AreEqual()…

MVC: Validation – Remote

Please see my other MVC articles. Using the Remote attribute to leverage JQuery’s validator. MVC provides a flexible and powerful method for using logic external to the Model for enforcing business rules – the Remote attribute. In this article, I will illustrate how to use an action method from a Controller to validate a Model’s…

MVC: Validation – Model

Please see my other MVC articles. Enforcing Model-level validation. MVC enables validation to be performed at the model-level by implementing the IValidatableObject interface. Once you’ve defined Validate(), your routines then may perform custom validation using the Model’s properties. To illustrate this feature, I’ll implement a routine to ensure the territory entered is one of the…

MVC: Validation

Please see my other MVC articles. Utilizing validation in the model to enforce business rules. In this article, I will illustrate some of the basic validation types available to ensure business rules for data are enforced. Since MVC provides this capability within the Model, separation of concerns are maintained by keeping this logic out of…

MVC: Using ViewBag for Data Storage

Please see my other MVC articles. Passing data to a View. Sometimes a business requirement necessitates data to passed from a Controller to the View for displaying to the user. One method MVC provides is the object ViewBag which allows you to easily attach inference-typed variables for initialing with many types of data. To illustrate…

MVC: User Context Info

Please see my other MVC articles. Using context objects to discern user information. This article illustrate how easy ASP.NET MVC allows access to a wealth of user information. Notice from my code, I simply access just a few object to retrieve almost everything about the user. Here are the results of my code, showing my…

MVC: Regular Expressions

Please see my other MVC articles. Enforcing valid formats on user input. Most user-input forms’ business rules indicate specific formats for the data they receive. MVC enables developers to enforce those rules very easily by using regular expression within their custom models. To illustrate this feature, I will begin with a simple Create form. As…

MVC: Razor Syntax

Please see my other MVC articles. Implementing logic into the Presentation layer. Perhaps one of the best features provided by MVC is the ability to implement logic into the UI to control output. To illustrate this feature, I’ll begin where my MVC: Action Methods using GET & POST article left off. As you can see,…

MVC: Links to Action Methods

Please see my other MVC articles. Using HTML links to execute controller action methods. It’s common to have a requirement that a controller’s action method be called from several different pages within a site. Also, this knowledge usually won’t be entirely flushed out at the beginning of project development. To compensate for this need, MVC…

MVC: Grid

Please see my other MVC articles. Leveraging the MVC Grid to quickly display sortable, paging data. MVC provides robust data controls for displaying data sets. These grids come with many customizable features and require very little coding. To illustrate this feature, I’ll begin a Model for Sales Associates. Next, I’ll create a Controller which seeds…