Reputation: 293
I am working on MVC3, i have a situation where i want to do something like this:
<Div>
@Code
Dim i = 1
End Code
....
some where, i want to increment i's value, expect 'i' value should be incremented by 1 for subsequent use.
@i = @i + 1
..
</div>
but razor is throwing wrong syntax error message. Could someone help me how to do this properly in side razor code.
Thank you, Rey.
Upvotes: 1
Views: 12348
Reputation: 27585
I don't know VB, but in C# u can use
@{i = i + 1;}
or
@{ i++; /* or i += 1; */ }
UPDATE: I think in VB must be:
@Code
i = i + 1
End Code
test it!
UPDATE: I create a MVC3 app with VB and test this code:
@Code
ViewData("Title") = "Index"
Dim i = 0
End Code
<h1>@i</h1>
<h2>Index</h2>
@Code
i = i + 1
End Code
<h1>@i</h1>
It works! post your markup, if u can.
Upvotes: 6