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…

MVC: Entity Framework

Please see my other MVC articles. Using Microsoft’s powerful ORM tool to perform data-layer operations. Most tasks performed in today’s data-driven websites revolved around one or more of the Create-Retrieve-Update-Delete (C.R.U.D.) operations. Microsoft has provided a very elegant, easy-to-use, yet powerful tool that abstracts a lot of the complexity necessary for most CRUD operations while…

MVC: Custom Model

Please see my other MVC articles. Developing a custom model to encapsulate a unique domain. The Model serves as the heart of the MVC application, containing a domain’s business logic. In this example, I will illustrate how to create a custom Model representing a typical sales associate within any company. Also, I will build a Create View…

MVC: ContentResult

Please see my other MVC articles. Returning different types of content. MVC provide flexibility when answering requests for resources by supporting different types of content. In this article, I will illustrate the use of the ContentType to return plain text and XML. Here I have a simple example of how a Controller may return plain…

MVC: C.R.U.D. Operations

Please see my other MVC articles. Using Entity Framework to leverage CRUD operations within a website. Most tasks performed in today’s data-driven websites revolved around one or more of the Create-Retrieve-Update-Delete (C.R.U.D.) operations. Microsoft has provided a very elegant, easy-to-use, yet powerful tool that abstracts a lot of the complexity necessary for most CRUD operations…