Have to embed javascript code block with
<script type='text/javascript'>
...
</script>
But Razor code won’t compile in a .js file, included from a .cshtml file.
How to make this work? Or is there any other elegant way to have a similar effect?
Thank you.
When I face this problem sometimes I will provide a function in the .js file that is accessible in the .cshtml file…
Not necessarily the BEST option, but it’ll do if you have to do it…
The other thing you could maybe try is using data attributes on your html elements like how jQuery.validate.unobtrusive does…