Monday 11 December 2017

ASP.NET MVC razor: conditional attribute in HTML

MVC4 beta has conditional attributes built in...
<div @{if (myClass != null) { <text>class="@myClass"</text> } }>Content</div>
<div class="@myClass">Content</div>
If @myClass is null, it just won't use the attribute at all...
I know that may not quite solve your current issue, but it is noteworthy!

No comments:

Post a Comment

Note: only a member of this blog may post a comment.