In an ASP.NET MVC application I am working on, <text>
tags are being used in a .cshtml
file.
Example -
<text>some text</text>
What functionality do they provide? I can not find any reference to them on the interweb :)
Thanks!
The are kinda the opposite of the @ tags...
Standard in views you are in "HTML-mode", you can then use a Razor-block like this:
@{
//Razor code
}
Razor will detect HTML-tags in a razor block and render that but sometimes you just need to show the literal text. That's where the tag comes in... It switches back to HTML-mode without using an actual HTML-tag...
So some text will render that exact text (WITHOUT the tag>) in your view: Convaluted example, but this code:
<div>
you have
@{
if(numItems == 0)
{
<text>no</text>
}
else
{
@numItems
}
}
items
</div>
Will render "You have no items" or "you have 5 items" for example...
This element for identifying content explicitly. You can read information about this here: http://weblogs.asp.net/scottgu/archive/2010/12/15/asp-net-mvc-3-razor-s-and-lt-text-gt-syntax.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With