Simple program to understand the concept of Razor

Amatya
Posted by Amatya under ASP.NET MVC category on | Points: 40 | Views : 2046
Razor is a view engine supported in MVC 3.Its syntax is compact and of less characters.
The @ character starts inline expressions, single statement blocks, and multi-statement blocks:


<!-- Single statement blocks  -->
@{ var amount = 100000; }
@{ var dnfMessage = "Hello DNF Members"; }

<!-- Inline expressions -->
<H2>DNF Account amount: @amount </H2>
<H3>DNF Message: @dnfMessage</H3>

<!-- Multi-statement block -->
@{
var dnfGreeting = "Welcome to DNF website";
var weekDay = DateTime.Now.DayOfWeek;
var dnfGreetingMessage = dnfGreeting + " Today is: " + weekDay;
}
<p>The greeting is: @dnfGreetingMessage</p>


Thanks
Amatya

Comments or Responses

Login to post response