Reputation: 193
I know the solution for this should be simple, but I can't figure it out. When I add a number (for example 2) to page variable, it actually considers it as a string and shows: instead of 3 : 1+2
@{
var page= 1 ;
}
<li>@page+2</li>
Upvotes: 1
Views: 265
Reputation: 67080
Expression must be evaluated server side so it must be enclosed in parenthesis:
<li>@(page+2)</li>
If you don't then parser will evaluate server side only first token after @, page
will be replaced with its value and you'll have <li>1+2</li>
HTML text (where, of course, no more evaluation will be performed).
Upvotes: 2