在使用MVC3 RC1razor视图时,我在javascript块中嵌入c#代码遇到了问题。我应该使用什么语法才能使它起作用?我收到警告,例如isOk变量上的Expected constant等警告。(如果没有text标签,以下代码将不被识别为javascript)
@{bool isOk = true;}
<script type="text/javascript">
var tmp1 = "";
@if (isOk)
{
<text>
var tmp=""; // this should be interpreted as javascript
</text>
}
</script>