Code With Examples

Razor Markup in ASP.NET

Written by Zaheer Alam

Razor Markup in ASP.NET

To embedding server code in C# or in VB .NET you may use Razor, it’s really simple markup syntax for ASP.NET web pages.


ViewBag.Title = “Home Page”;
<!– Single statement block –>
@{ var myMessage = “”; }

<!– Inline expression or variable –>
<p>The value of myMessage is: @myMessage</p>

<!– Multi-statement block –>
var greeting = “!”;
var weekDay = DateTime.Now.DayOfWeek;
var greetingMessage = greeting + ” Today is: ” + weekDay;
<p>The greeting is: @greetingMessage</p>

About the author

Zaheer Alam

Zaheer Alam is an Software Engineer Graduated From Well Versed institute of Aisa, Comsats University.He is inclined toward helping People improve their Programming Skill to the Next Level.He also works work as social media content creator on various pages and groups with the huge fan following.

Leave a Comment