Introducing Razor<br />A new view engine for ASP.NET<br />Shiju Varghese<br />Blog : http://weblogs.asp.net/shijuvarghese<...
Who Am I?<br />Microsoft MVP on ASP.NET<br />Solution Architect<br />Focus on Microsoft Web Platform stack<br />Agile Enth...
Session Objectives<br />Introduction to Razor<br />Introduction to Razor Syntax<br />Demonstrate Razor syntax in ASP.NET M...
New tools from Microsoft Web Platform<br />Web Matrix<br />IIS Express<br />ASP.NET Web Pages<br />SQL Server Compact <br ...
Introduction to Razor<br />A new view-engine option for ASP.NET<br />A simplified syntax<br />Its not a new language <br /...
ASP.NET Razor Support<br />ASP.NET Web Pages<br />Using for inline programming<br />ASP.NET MVC 3<br />Using for ASP.NET M...
@ character<br />@ character is using for insert server side code<br />Single statement blocks<br />@{ varmyMessage = "Hel...
Razor Syntax<br />Web Forms syntax<br />	<% for (int i = 0; i < 10; i++) { %><br />	     <li><% =i %></li><br />	<% } %><b...
Razor Syntax<br />@{<br />var name = “Shiju”;<br />var title=“Architect”;<br />	<div><br />Name: @name<br />	Title: @title...
Layout page<br />Share common html across many pages<br />Layout page:<br />_LayoutPage.cshtml<br /><html><br /><title>@Pa...
Using Layout page<br />@{<br />Page.Title = “Your Page Title”;<br />	Layout = "_Layout.cshtml";<br />}<br />
_PageStart.cshtml<br />Run code for each page<br />Setup layout page for an entire folder<br />
Using Helper<br />App_Code/RazorHelper.cshtml<br />@helper ShowCopyright() {<br /><div><br />Copyright Shiju Varghese @Dat...
Demo<br />
Thanks<br />
Upcoming SlideShare
Loading in...5
×

Introducing Razor - A new view engine for ASP.NET

3,890

Published on

An Introducing to Razor view engine for ASP.NET

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
3,890
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
165
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Introducing Razor - A new view engine for ASP.NET

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

    Clipping is a handy way to collect important slides you want to go back to later.

×