1.

Can I Use Razor Code In Javascript In Mvc?

Answer»

Yes. We can use the RAZOR code in JAVASCRIPT in cshtml by<text&GT;usingelement.

 <script type="text/javascript">

@foreach (VAR ITEM in Model) {

<text>

//javascript goes here which uses the server values

</text>

}

</script>

Yes. We can use the razor code in javascript in cshtml by<text>usingelement.

 <script type="text/javascript">

@foreach (var item in Model) {

<text>

//javascript goes here which uses the server values

</text>

}

</script>



Discussion

No Comment Found