Mvc C#无效字符 [英] Mvc C# invalid character

查看:93
本文介绍了Mvc C#无效字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我的.cshtml中有错误,但找不到抱怨无效字符的原因。


我有一个内联脚本部分。见下文:



Dear Friends,

I have a error in my .cshtml but can't find a reason why it is complaining about a invalid character.

I have a inline script section. see below:

}
<script>
    function setBanner(bool){
        if (bool == 'true')
        {
            $('.banner').attr('data', 'false');
            $('.Priority-control').attr('value', false);
            $('#image-source').attr('src', '/Content/images/Banner-laag.png');
        } else {
            $('.banner').attr('data', 'true');
            $('.Priority-control').attr('value', true);
            $('#image-source').attr('src', '/Content/images/Banner-important.png');
        }
    };
</script>

@Html.HiddenFor(m => m.FollowupId)





之前结束标记它告诉我我有一个无效的字符

'无效字符'< / script>



我有5个脚本部分。其中3个人在脚本部分的结束标记前面说无效字符。



有解决方案可以解决这个问题吗?

删除并重新键入它直到关闭并重新打开文档。



快速操作和重构的潜在修复只提供删除脚本部分的选项。



更新:

我跑了 jslint

这是说:





Before the closing tag it tells me I have a invalid character
'invalid character' </script>

I have 5 script sections. 3 of them are saying 'invalid character' in front of the closing tag of the script section.

Anyone who have a solution to fix this problem?
Removing and retype solves it till closing and reopening the document.

Potential fixes from 'Quick actions and refactoring' only gives the option to remove script section.

Update:
I runned jslint
It is saying:

Expected '/'.
                    </script>



看不出原因......



我尝试过:



- 快速操作和重构的潜在修复

- 删除并重新输入脚本部分。

- 将所有部分合并到一个脚本部分。

- 重新启动visual studio 2015.

- 清理/重建



- 将qoute替换为double qoute。

- 删除结束标记{

- 删除;


Can't see why...

What I have tried:

- Potential fixes from 'Quick actions and refactoring'
- Removing and retype script sections.
- combining all sections to one script section.
- restarting visual studio 2015.
- clean/ rebuild

- replacing qoute for double qoute.
- removing end tag {
- removing ;

推荐答案

' .flag''/ / span>)。attr(' data'' false');


' 。优先级 - control')。attr(' value' false );
('.Priority-control').attr('value', false);


' # image-source')。attr(' src'' / Content / images / Banner-laag.png');
} 其他 {
('#image-source').attr('src', '/Content/images/Banner-laag.png'); } else {


这篇关于Mvc C#无效字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆