| Below i have given some syntax of razor as well as some comparison with the old technlogies used before Razor
(1)First for datetime
(i)New Razor code for datatime
@DateTime.Now
(ii)Old code for datetime
< % =DateTime.Now%>
(2)Syntax for ForEach loop
@foreach (string obj in obj)
{
@obj
}
(3)Code for multiple lines we will add @ at first row
@{
List objlst = new List ();
objlst.Add("dotnet");
objlst.Add("java");
objlst.Add("php");
objlst.Add("sql");
}
(4)To HTML display with Razor
@{
var link = "< a href='http://www.getproductprice.com'>Click here< /a>";
}@link;
Here in above code you will get output as < a href='http://www.getproductprice.com' >Click here
(5)ANd to display link we use below code
@{
var link = "< a href='http://www.getproductprice.com' >Click here< /a>";
@Html.Raw(link);
Now with above code will will get link Click Here only | | |