Introducing the ASP.NET MVC 3
Upcoming SlideShare
Loading in...5
×
 

Introducing the ASP.NET MVC 3

on

  • 1,705 views

 

Statistics

Views

Total Views
1,705
Views on SlideShare
1,705
Embed Views
0

Actions

Likes
0
Downloads
9
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • 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'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.

Introducing the ASP.NET MVC 3 Introducing the ASP.NET MVC 3 Presentation Transcript

  • ASP.NET MVC 3 Training for Heroes
    WELCOME TO MVC SHINE DAY
    LêDươngCôngPhúc
    SESSION 2: ASP.NET MVC 3 OVERVIEW
  • Who am I?
    LêDươngCôngPhúc
    Technical evangelism
    Software engineer at Vina Digital Co,. Ltd.
  • Introducing “MVC Shine” application
    Exercise 2
    Implementing simple CRUD functionalities using Razor view engine
  • Razor Syntax
    @if (User.Grok(Razor)) {
    <div>w00t!</div>
    }
    • 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
  • Web Forms vs. PHP vs. Razor
    Web Forms (6 markup transitions):
    <ul>
    <% for (int i = 0; i < 10; i++) { %>
    <li><% =i %></li>
    <% } %>
    </ul>
    <ul>
    <?php
    for ($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):
  • Razor Syntax
  • Directives
  • Layouts make organizing your pages easier
    Don’t repeat yourself!
    Define one layout and use it across your website
    Page 1
    Layout.cshtml
    Page 2
    Page 3