ASP.NET MVC 3 Training for Heroes <br />WELCOME TO MVC SHINE DAY<br />LêDươngCôngPhúc<br />SESSION 2: ASP.NET MVC 3 OVERVI...
Who am I?<br />LêDươngCôngPhúc<br />Technical evangelism<br />Software engineer at Vina Digital  Co,. Ltd.<br />
Introducing “MVC Shine” application<br />Exercise 2<br />Implementing simple CRUD functionalities using Razor view engine ...
Razor Syntax<br />@if (User.Grok(Razor)) {<br />	<div>w00t!</div><br />}<br /><ul><li>New, Simplified View Engine
Write fewer lines of code
More natural mix code and markup
Helpers save you time
Compatible with ASP.NET Web Pages in WebMatrix</li></li></ul><li>Web Forms vs. PHP vs. Razor<br />Web Forms (6 markup tran...
Upcoming SlideShare
Loading in …5
×

Introducing the ASP.NET MVC 3

1,790 views
1,749 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,790
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Estimated Time: 2 mins
  • Note – only use this slide if you are using ASP.NET MVC 3With ASP.NET MVC 3 we’ve 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.
  • 2 minutesWe’ve 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 it’s the easiest way to code websites and when you compare it to the other languages out there, it’s easy to see why.
  • 1 minuteThe bigger your site, the more pages you’ll 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&apos;t include any actual content. After you&apos;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.
  • Introducing the ASP.NET MVC 3

    1. 1. ASP.NET MVC 3 Training for Heroes <br />WELCOME TO MVC SHINE DAY<br />LêDươngCôngPhúc<br />SESSION 2: ASP.NET MVC 3 OVERVIEW<br />
    2. 2. Who am I?<br />LêDươngCôngPhúc<br />Technical evangelism<br />Software engineer at Vina Digital Co,. Ltd.<br />
    3. 3. Introducing “MVC Shine” application<br />Exercise 2<br />Implementing simple CRUD functionalities using Razor view engine <br />
    4. 4. Razor Syntax<br />@if (User.Grok(Razor)) {<br /> <div>w00t!</div><br />}<br /><ul><li>New, Simplified View Engine
    5. 5. Write fewer lines of code
    6. 6. More natural mix code and markup
    7. 7. Helpers save you time
    8. 8. Compatible with ASP.NET Web Pages in WebMatrix</li></li></ul><li>Web Forms vs. PHP vs. Razor<br />Web Forms (6 markup transitions):<br /><ul><br /><% for (int i = 0; i < 10; i++) { %><br /> <li><% =i %></li><br /><% } %><br /></ul><br /><ul><br /><?php<br />for ($i = 0; $i < 10; $i++) {<br />echo("<li>$i</li>");<br /> } <br /> ?><br /></ul><br />PHP(2 markup transitions & an echo):<br /><ul><br />@for (int i = 0; i < 10; i++) {<br /> <li>@i</li><br /> }<br /></ul><br />Razor (2 markup transitions):<br />
    9. 9. Razor Syntax<br />
    10. 10. Directives<br />
    11. 11. Layouts make organizing your pages easier<br />Don’t repeat yourself!<br />Define one layout and use it across your website<br />Page 1<br />Layout.cshtml<br />Page 2<br />Page 3<br />

    ×