111
rated 0 times
[
116]
[
5]
/ answers: 1 / hits: 26373
/ 12 Years ago, mon, september 10, 2012, 12:00:00
Possible Duplicate:
using razor within javascript
I would like to place a siimple value from the model on a razor page and use it as a constant value in a javascript function. i.e.
<script> var myValue = @Model.myRecord.Count();</script>
so that myValue = the record count in my model. I am using myRecord.Count as an example, it could be any value from my model.
Is this possible?
TIA
J
OK I stumbled across the following solution:
<script> var myValue = @(Model.myRecord.Count())</script>
Just putting inthe extra brackets helped.
More From » asp.net-mvc