Suggested Videos
Part 55 - What is cross site scripting attack
Part 56 - How to prevent cross site scripting attack
Part 57 - Razor views in mvc
In this video, we will discuss razor view syntax. This is continuation to Part 57, so please watch Part 57, before proceeding.
Use @* *@ to comment in razor views
@*This is a comment
in razor views*@
Transition between c# expressions and literal text
@{
int day = 31;
int month = 12;
int year = 2013;
}
Date is @day-@month-@year
Output:
Date is 31-12-2013
Using explicit code nugget
@for (int i = 1; i <= 5; i++)
{
<img src="~/Images/@(i).png" />
}
The above code generates the following HTML
<img src="/MVCDemo/Images/1.png" />
<img src="/MVCDemo/Images/2.png" />
<img src="/MVCDemo/Images/3.png" />
<img src="/MVCDemo/Images/4.png" />
<img src="/MVCDemo/Images/5.png" />
Output:
@ symbol is used as code delimiter in razor views. However, razor is smart enough to recognize the format of internet email address and not to treat the @ symbol as a code delimiter.
This is my email address<br />
<b>kudvenkat@gmail.com</b>
Use @ symbol to escape @
I will meet you @@ office
Output:
I will meet you @ office
Part 55 - What is cross site scripting attack
Part 56 - How to prevent cross site scripting attack
Part 57 - Razor views in mvc
In this video, we will discuss razor view syntax. This is continuation to Part 57, so please watch Part 57, before proceeding.
Use @* *@ to comment in razor views
@*This is a comment
in razor views*@
Transition between c# expressions and literal text
@{
int day = 31;
int month = 12;
int year = 2013;
}
Date is @day-@month-@year
Output:
Date is 31-12-2013
Using explicit code nugget
@for (int i = 1; i <= 5; i++)
{
<img src="~/Images/@(i).png" />
}
The above code generates the following HTML
<img src="/MVCDemo/Images/1.png" />
<img src="/MVCDemo/Images/2.png" />
<img src="/MVCDemo/Images/3.png" />
<img src="/MVCDemo/Images/4.png" />
<img src="/MVCDemo/Images/5.png" />
Output:
![explicit code nugget](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixMm_2JaCy9vCkkAhQqrAkDLP_38Id3kpT5dTK6LCmfaJZy-yxoZMC9EHRHnMJ-HUayJfKu_alIdGk7uTSQt9sy4SUZos54E5m9GvC_tYu-WI_8xep6JJWT8OB-Y_XqFKC32EYydFpW0DM/s1600/explicit+code+nugget.png)
@ symbol is used as code delimiter in razor views. However, razor is smart enough to recognize the format of internet email address and not to treat the @ symbol as a code delimiter.
This is my email address<br />
<b>kudvenkat@gmail.com</b>
Use @ symbol to escape @
I will meet you @@ office
Output:
I will meet you @ office
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAPt-mbLGuR0mWO5nO3IhmZMzuY8vpuY_20EJfsVD5nYa0JYN7psgz22DfXrk2bemwRgGnzUV1Eh_f83bVbei6NFE8FtDNYl5zWRpHT06bjJjz9EXyizew5srnSXmn2QiwOIjhc4ItqDB0/s1600/asp.net+mvc+tutorial.png)
No comments:
Post a Comment
It would be great if you can help share these free resources