简体   繁体   中英

HTML onclick JavaScript function call always highlighted red Razor View/C#

Occasionally with <button> or <a> elements when a JavaScript function is passed to the onclick or similar event, the end of the function is highlighted red, still works fine, but I find it really distracting seeing red lines on the code map for no reason.

<button onclick="MyApp.SaveRate(this);"></button>
<button onclick="MyApp.SaveRate(this)"></button>

<a onclick="MyApp.SaveRate(this);"></a>
<a onclick="MyApp.SaveRate(this)"></a>

It's highlighted in all cases from above, on hover it says Unterminated string constant

Is there a way of stopping this?

You can resolve it by deleting the cache files located in:

C:\Users\your.name.here\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache

Restart Visual Studio.

The files will be recreated when you next launch Visual Studio, and they should now be error-free.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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