I am trying to get a C# variable cSharpString copied over to a JavaScript variable filename in my MVC view.
@{
ViewData["Title"] = "Title";
}
@section head {
@{
string cSharpString = "Hello World";
<script type="text/javascript">
var filename = "<%=cSharpString%>";
</script>
}
}
When debugging in Chrome and entering the JavaScript variable name the console outputs the C# code instead of the variable name like I would expect.
filename "<%=cSharpString%>"