asp.net mvc - Warning on Razor when <img width="@someVar"> -
having following .cshtml :
@{ int somevar = 300; } <img width="@somevar">
visual studio (2012) gives me warning :
warning 1 '@width' not valid value of attribute 'width'.
it work ok, i'm wondering if there's way pass variable width attribute without having warning.
thanks!
just wrap value in parentheses, so:
@{ int somevar = 300; } <img width="@(somevar)">
the warning should disappear.
Comments
Post a Comment