I\'m looking for a way to write the following code with less lines of code (maybe 5). I suppose I could do the same thing as the selected class but this razor syntax isn\'t
see http://weblogs.asp.net/jgalloway/archive/2012/02/16/asp-net-4-beta-released.aspx
Conditional attribute rendering
If you have an attribute that might be null, in the past you've needed to do a null check to avoid writing out an empty attribute, like this:
class="@myClass" } }>Content
Now Razor is able to handle that automatically, so you can just write out the attribute. If it's null, the attribute isn't written:
Content
So if @myClass is null, the output is just this:
Content