Search This Blog
Sunday, July 15, 2012
Saturday, July 14, 2012
Examining the Edit Methods and Edit View (C#)
In this section, you'll examine the generated action methods and views for the movie controller. Then you'll add a custom search page.
Run the application and browse to the
Movies
controller by appending /Movies to the URL in the address bar of your browser. Hold the mouse pointer over an Edit link to see the URL that it links to.Adding a New Field to the Movie Model and Table (C#)
In this section you'll make some changes to the model classes and learn how you can update the database schema to match the model changes.
Adding a Rating Property to the Movie Model
Start by adding a new
Rating
property to the existing Movie
class. Open the Movie.cs file and add the Rating
property like this one:public string Rating { get; set; }
The complete
Movie
class now looks like the following code:Accessing your Model's Data from a Controller (C#)
In this section, you'll create a new
MoviesController
class and write code that retrieves the movie data and displays it in the browser using a view template. Be sure to build your application before proceeding.
Right-click the Controllers folder and create a new
MoviesController
controller. Select the following options:- Controller name: MoviesController. (This is the default. )
- Template: Controller with read/write actions and views, using Entity Framework.
- Model class: Movie (MvcMovie.Models).
- Data context class: MovieDBContext (MvcMovie.Models).
- Views: Razor (CSHTML). (The default.)
Adding a Model (C#)
Adding a Model
In this section you'll add some classes for managing movies in a database. These classes will be the "model" part of the ASP.NET MVC application.
You’ll use a .NET Framework data-access technology known as the Entity Framework to define and work with these model classes. The Entity Framework (often referred to as EF) supports a development paradigm called Code First. Code First allows you to create model objects by writing simple classes. (These are also known as POCO classes, from "plain-old CLR objects.") You can then have the database created on the fly from your classes, which enables a very clean and rapid development workflow.
Adding a Controller (C#)
Adding a Controller (C#)
VC stands for model-view-controller. MVC is a pattern for developing applications that are well architected and easy to maintain. MVC-based applications contain:
- Controllers: Classes that handle incoming requests to the application, retrieve model data, and then specify view templates that return a response to the client.
- Models: Classes that represent the data of the application and that use validation logic to enforce business rules for that data.
- Views: Template files that your application uses to dynamically generate HTML responses.
We'll be covering all these concepts in this tutorial series and show you how to use them to build an application.
Let's begin by creating a controller class. In Solution Explorer, right-click the Controllers folder and then select Add Controller.
Friday, July 6, 2012
Source Code: MVC 3 Introduction
Source Code: MVC 3 Introduction: Introduction This tutorial will teach you the basics of building an ASP.NET MVC Web application using Microsoft Visual We...
MVC 3 Introduction
Introduction
This tutorial will teach you the basics of building an ASP.NET MVC Web application using Microsoft Visual Web Developer 2010 Express Service Pack 1, which is a free version of Microsoft Visual Studio. Before you start, make sure you've installed the prerequisites listed below.
Recommended Prerequisites
- Visual Studio 2010 SP1
- SQL Express
- ASP.NET MVC 3 (If you have already properly installed Visual Studio 2010 SP1, it is already there, else you will find it over here.)
Subscribe to:
Posts (Atom)