The Razor view engine automatically differentiates between Server code and Html Code For example this code works very fine
@if (DateTime.Now.Year == 1983)
{
if (DateTime.Now.Month == 9)
{
<p>Wow, this month Shay is born!</p>
}
}
else
{
<p>It's the new millenium dude!</p>
}
But if I want to show html tags or anchor tags in the text then what escape character should I use?
Like in the above example I want to show the else message like this
else
{
<p>It's the new <millenium> dude!</p>
}
Use regular HTML escape sequences: <millenium>
You have to use
<p>It's the new <millenium$gt; dude!</p>
But that's not a Razor issue, it's HTML. If you want to display <
or >
you have to use the HTML entities instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.