Introducing Razor - A new view engine for ASP.NET
Upcoming SlideShare
Loading in...5
×
 

Introducing Razor - A new view engine for ASP.NET

on

  • 4,156 views

An Introducing to Razor view engine for ASP.NET

An Introducing to Razor view engine for ASP.NET

Statistics

Views

Total Views
4,156
Views on SlideShare
3,883
Embed Views
273

Actions

Likes
0
Downloads
143
Comments
0

3 Embeds 273

http://www.techgig.com 261
http://www.linkedin.com 10
https://www.linkedin.com 2

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

Introducing Razor - A new view engine for ASP.NET Introducing Razor - A new view engine for ASP.NET Presentation Transcript

  • Introducing Razor
    A new view engine for ASP.NET
    Shiju Varghese
    Blog : http://weblogs.asp.net/shijuvarghese
    Twitter : http://twitter.com/shijucv
    Email : shiju.varghese@gmail.com
  • Who Am I?
    Microsoft MVP on ASP.NET
    Solution Architect
    Focus on Microsoft Web Platform stack
    Agile Enthusiast
    Technology Consultant – Web Apps/ASP.NET MVC/EF
    Blog: http://weblogs.asp.net/shijuvarghese
    Twitter: @shijucv
  • Session Objectives
    Introduction to Razor
    Introduction to Razor Syntax
    Demonstrate Razor syntax in ASP.NET MVC 3 Views
  • New tools from Microsoft Web Platform
    Web Matrix
    IIS Express
    ASP.NET Web Pages
    SQL Server Compact
    Razor
    NuGet
  • Introduction to Razor
    A new view-engine option for ASP.NET
    A simplified syntax
    Its not a new language
    A code focused templating syntax optimized around HTML generation
    Shared by ASP.Netweb pages and ASP.Net MVC
    Works with any Text Editor
    IntelliSense with Visual Studio 2010/ VWD 2010
    CSHTML (C#) and VBHTML (VB.NET)
    Unit Testable
  • ASP.NET Razor Support
    ASP.NET Web Pages
    Using for inline programming
    ASP.NET MVC 3
    Using for ASP.NET MVC Views
    Tools
    Web Matrix
    Visual Studio 2010
    Visual Web Developer 2010
    Languages
    C#
    VB.Net
  • @ character
    @ character is using for insert server side code
    Single statement blocks
    @{ varmyMessage = "Hello World"; }
    Starts inline expressions
    <p>The value of myMessage is: @myMessage</p>
    Multi-statement blocks
    @{
    var greeting = "Welcome to our Razor!";
    varweekDay = DateTime.Now.DayOfWeek;
    vargreetingMessage = greeting + " Today is: " + weekDay;
    }
  • Razor Syntax
    Web Forms syntax
    <% for (int i = 0; i < 10; i++) { %>
    <li><% =i %></li>
    <% } %>
    Razor syntax
    @for (int i = 0; i < 10; i++) {
    <li>@i</li>
    }
  • Razor Syntax
    @{
    var name = “Shiju”;
    var title=“Architect”;
    <div>
    Name: @name
    Title: @title
    </div>
    }
  • Layout page
    Share common html across many pages
    Layout page:
    _LayoutPage.cshtml
    <html>
    <title>@Page.Title</title>
    <body>
    <div> @Html.Partial("_Header") </div>
    @RenderBody()
    <div> @Html.Partial("_Footer")</div>
    </body>
  • Using Layout page
    @{
    Page.Title = “Your Page Title”;
    Layout = "_Layout.cshtml";
    }
  • _PageStart.cshtml
    Run code for each page
    Setup layout page for an entire folder
  • Using Helper
    App_Code/RazorHelper.cshtml
    @helper ShowCopyright() {
    <div>
    Copyright Shiju Varghese @DateTime.Now.Year
    </div>
    Using a Helper
    @RazorHelper.ShowCopyright()
  • Demo
  • Thanks