razor使用注意点........

使用三元运算符时记得加括号。。。。

如:

@Convert.ToInt32(Request.QueryString["type"])==0?true:false :这是错误的写法

@(Convert.ToInt32(Request.QueryString["type"])==0?true:false) 这是正确的写法!!!!!!!

把后台数据存入js中当变量用

var type = '@Convert.ToInt32(Request.QueryString["type"])';
            if (type == 1) {
                $("#atf-subsidyApply").show();
            }
            if (type == 2) {
                $("#atf-youfu").show();
            }
            if (type == 3) {
                $("#atf-societyHelp").show();
            }

原文地址:https://www.cnblogs.com/gaocong/p/4515059.html