简体   繁体   English

如何将TRUE从JavaScript传递到C#脚本

[英]How can I pass TRUE from javascript to a C# script

I have: 我有:

function SelectSubTopics() {
    $.ajax({
        url: "/Administration/Tests/SelectSubTopics",
        data: { DataSource: $('#DataSource').val(),
            testID: $('#TestID').val(),
            showAll: True
        },
        success: function (data) {
            $('#TID').html(data);
        }
    });
}

I would like to pass a value of True through to the C# program which accepts a bool for the showALL parameter but I am getting a javascript error saying "SCRIPT5009: 'True' is undefined " Is there some special way to pass true? 我想将True的值传递给C#程序,该程序接受showALL参数的布尔值,但是我遇到了一个JavaScript错误,提示“ SCRIPT5009:'True'未定义”,是否存在一些传递true的特殊方法?

Lower case: true - that's all. 小写: true -仅此而已。 If the case is important, use a string: "True" 如果大小写很重要,请使用字符串: "True"

Javascript is case-sensitive which means true is not True . Javascript区分大小写,这意味着true不是True Also note that showAll in your server-side script is not bool it's a string . 还要注意,服务器端脚本中的showAll不是bool而是string

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM