I have created a razor view (Demo.cshtml) and I tried to declare razor variable within javascript block as shown below:
Code:
@{
ViewBag.Title = "Demo";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>
Demo</h2>
<script type="text/javascript">
$(function () {
@{
bool test = true;
}
});
</script>
I am getting few warnings as mentioned below:
Warning 1 Invalid character Demo.cshtml 10 10 Warning 2 Expected ';' Demo.cshtml 11 18
Can anyone guide me in resolving the above warning?