Q:

Using Razor Syntax within JavaScript Conditional Statment

In an index.cshtml I have the following working code similar to:
<script type="text/javascript">

if ('@Model.SomeCondition' === 'True'){
Do Something();
}

</script>

The === 'True' seems like an odd hack to me to force Razor and JavaScript to get along. How can I refactor to use === true? This doesn't give the same result. Can this be done with Razor and JavaScript?

A:

If the property isbool, you can check in razor if condition following way:
<script type="text/javascript">
@if (Model.SomeCondition){
@:Do Something();
}
</script>

or:
<script type="text/javascript">
@if (Model.SomeCondition){
<text>
Do Something();
</text>
}    
</script>

