如何将javascript与razor代码混合使用

问题描述:

在剃刀(chtml)模板中添加以下javascript的语法是什么?

What the syntax to add the following javascript within my razor (chtml) template?

<script type="text/javascript">

 $(function(){ 
    @if(Model.IsModalShown)
    {
        $('#myModal').modal('show');
    }
 });

</script>

<script type="text/javascript">

$(function(){ 
    @if(Model.IsModalShown)
    {
        <text>$('#myModal').modal('show');</text>
    }
});

</script>

<script type="text/javascript">

$(function(){ 
    if('@Model.IsModalShown' == 'True')
    {
        $('#myModal').modal('show');
    }
});

</script>