In this chapter you will learn
So, I think that the Overview of Razor Markup and WebMatrix has finished. It's time to do some practical based activity. In this chapter you will write your First Razor Syntax in WebMatrix and debug your program to see output. In the previous chapter you have already learned how to use WebMatrix to write Razor Markup.
- Write Your First Razor Syntax in WebMatrix
- Execute Your Code
Programming Example
In this programming Example, I will show the current date and time in the browser using C# and Razor Markup.<html lang="en"> <head> <meta charset="utf-8" /> <title></title> </head> <body> @{ string year,day,month,time; year=DateTime.Now.Year.ToString(); day=DateTime.Now.DayOfWeek.ToString(); month=DateTime.Now.Month.ToString(); time=DateTime.Now.ToShortTimeString(); } <h5>Current Year: @year</h5> <h5>Current Day : @day</h5> <h5>Current Month: @month</h5> <h5>Current Time: @time</h5> </body> </html>
Output