I tried this for many days ... (I'm in the process of learning ASP.NET MVC 3)
This link - Razor If / Else conditional operator syntax - says that the only valid conditional expression syntax in the Razor engine is @ (x? Y: z)
Good. Now, how to write HTML in this conditional expression? I cannot use Razor here, the following code leads to an invalid syntax error.
@(item.Manager == null ? @:<i>unassigned</i> : item.Manager.Name)
After some research, I discovered HtmlWriter or Html.Raw, but neither of them, nor the methods of the .toString () or .toHtmlString () methods, because they are not from a string, but from an IHtmlString type.
Thanks for the answer!
Mirek
source share