Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
Razor and the Art of Templating
Next
Download to read offline and view in fullscreen.

2

Share

Download to read offline

Introducing Razor - A new view engine for ASP.NET

Download to read offline

An Introducing to Razor view engine for ASP.NET

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 />
  • nasir442

    Sep. 23, 2018
  • Soeheinoo

    May. 1, 2018

An Introducing to Razor view engine for ASP.NET

Views

Total views

5,362

On Slideshare

0

From embeds

0

Number of embeds

276

Actions

Downloads

243

Shares

0

Comments

0

Likes

2

×