Is there a way to pass boolean values from a controller to a view using ViewData and retrieve it as a boolean value in JavaScript?
Controller:
ViewData["isLogged"] = true;
View
<script type="text/javascript">
var isLogged = <%= (bool)ViewData["IsLogged"] %>; /// attempting this throws a JavaScript error
</script>
I can always do this instead:
<script type="text/javascript">
var isLogged = '<%= ViewData["IsLogged"] %>'; /// now isLogged is a string 'True'
</script>
However, I prefer to keep the isLogged object as a boolean rather than a string if possible.