quot to " in MVC

本文关键字:quot MVC in amp to | 更新日期: 2023-09-27 18:19:17

样本

<script>
 $('#data').jstree({
            'core': {
                'data': [@:{"text" : "ABC"},           @subtree();]}})
@function {
    public string subtree(){
        return  "{'"text'" : '"ABC'"}, "
    }
}
</script>

会变成

 $('#data').jstree({
                'core': {
                    'data': [{"text" : "ABC"},{&quot;text&quot; : &quot;ABC&quot;},]}})

我需要输出quot。我需要函数递归。我怎么解它?

quot to &quot; in MVC

由于@subtree();调用的字符串输出是自动转义的,您应该通过调用Html.Raw:

来防止这种情况的发生。
'data': [@:{"text" : "ABC"},           @Html.Raw(subtree());]}})