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

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -