This document provides an overview of an ASP.NET MVC 3 training session. It introduces the speaker and their background. It also discusses implementing simple CRUD functionality using the Razor view engine. Razor syntax is explained, including directives and layouts which allow organizing pages without repetition. An example compares Razor, PHP, and Web Forms markup and transitions.
1 of 8
Downloaded 13 times
More Related Content
Introducing the ASP.NET MVC 3
1. ASP.NET MVC 3 Training for Heroes WELCOME TO MVC SHINE DAYL棚D動董ngC担ngPh炭cSESSION 2: ASP.NET MVC 3 OVERVIEW
8. Compatible with ASP.NET Web Pages in WebMatrixWeb Forms vs. PHP vs. RazorWeb Forms (6 markup transitions):<ul><% for (int i = 0; i < 10; i++) { %> <li><% =i %></li><% } %></ul><ul><?phpfor ($i = 0; $i < 10; $i++) {echo("<li>$i</li>"); } ?></ul>PHP(2 markup transitions & an echo):<ul>@for (int i = 0; i < 10; i++) { <li>@i</li> }</ul>Razor (2 markup transitions):
#5: Note only use this slide if you are using ASP.NET MVC 3With ASP.NET MVC 3 weve added a new view engine which uses a new lightweight syntax called Razor. Razor is designed to make it easier and faster to write code and allows you to mix markup and code for more understandable views. The new syntax is characterized by the new @ symbol that you will see commonly in Razor views and allows you to mix code and markup freely, which makes for much cleaner code.Razor also allows you to make use of Helpers which are shortcuts that make it easier to use common plugins like ReCapture, Facebook Social Plugins, OData etc.The Razor syntax is actually borrowed from the younger sibling of MVC, ASP.NET Web Pages, with a few modifications that are added on top. For example MVC adds the @model keyword so that you no longer have to specify the full namespace in your directive when you are referencing models or ViewModels.
#6: 2 minutesWeve designed Razor to be super concise and easy to use. When we think about the way developers use a language we take into account the context switching they have to do and also the number of keystrokes. The way that Razor allows you to transition seamlessly between markup and code makes for a much more natural and fluent style and also helps to reduce the number of keystrokes and context switching that a developer has to do, thinking about markup and code separately. With Razor, markup and code are really the same thing.We think its the easiest way to code websites and when you compare it to the other languages out there, its easy to see why.
#9: 1 minuteThe bigger your site, the more pages youll have. One thing to keep in mind when building websites is how it will be navigated by users. The content usually changes from one page to the other, but the structure of the site, its menu, links, images, remain constant across all pages. As you add new pages and functionality, chances are that you find yourself repeating the same markup (HTML) , copy and pasting code across multiple pages to keep this consistency, and having to make changes everywhere every time you want to change the appearance of the website, etc.Here is were layouts come to the rescue!Layoutpages allow you to organize commonly used markup and code into one file and then reuse it across multiple pages on your website. They are pages that contain HTML-formatted content that can be shared by pages on the website. A layout page defines the structure of the web page, but doesn't include any actual content. After you've created a layout page, you can create web pages with content and then link them to the layout page. When these pages are displayed, they will be formatted according to the layout page.