javascript - Format code in Razor section visual studio -
i have project asp.net mvc in visual studio 2017 (enterprise edition) in layout page have 3 sections
<script type="text/javascript"> $(document).ready(function () { if(checkuserhavemobilephone) { @rendersection("scriptsphone", false) } else { @rendersection("scriptspc", false) } @rendersection("scripts", false) }); </script>
and in view have code (and work)
<script type="text/javascript"> @section scripts { $(window).resize(function () { }); } </script>
but when add if-statement section don't work
<script type="text/javascript"> @section scripts { $(window).resize(function () { if (parseint($(window).width()) <= 800) { alert("alert"); } }); } </script>
after syntax error
expected character '}'
<script type="text/javascript"> @section scripts { <text> $(window).resize(function () { if (parseint($(window).width()) <= 800) { alert("alert"); } }); </text> } </script>
try text tag, should working.
Comments
Post a Comment