asp.net mvc - 'x' is a 'variable' but is used like a 'method' -
i'm struggling curious situation. have collection of pages mean iterate through in razor. need twice, once within script tag , once outside. now, understand razor meant generate html , not javascript working fine , it's breaking , can't figure out quite why. here's code breaks:
<script type="text/javascript"> @foreach (string page in pages) { <text> function @page() { // here } </text> } </script>
this works fine:
<div class="intro"> @foreach (string page in pages) { <div id="@page"> <!-- whatever --> </div> } </div>
compiler error message: cs0118: 'page' 'variable' used 'method'
and points use of @page
. in fact vs13 red-squiggles use of variable but in first case!
what's going on here?
try
<script type="text/javascript"> @foreach (string page in pages) { <text> function @(page)() { // here } </text> }
Comments
Post a Comment