开发者

ASP.NET MVC markup in VS2008 script has warnings with "expected expression"

开发者 https://www.devze.com 2022-12-17 00:19 出处:网络
I\'ve searched SO and have been unable to find this question asked before, but I can\'t believe I\'m the only one running into it.If this is a duplicate, please point me to the original question.

I've searched SO and have been unable to find this question asked before, but I can't believe I'm the only one running into it. If this is a duplicate, please point me to the original question.

In VS2008, I have some ASP.NET MVC markup in a script section on some of my pages. I end up getting "expected expression" warning squiggles on the ASP.NET MVC markup even though the jQuery/JavaScript in the preceding code is valid. It only happens on the markup.

This doesn't prevent the page from rendering, everything works fine. It is more an annoyance than anything else. I've installed V开发者_JAVA百科S2k8 SP1 along with the Intellisense hotfix and it still happens. It also happens whether I'm running R# 4.5 or the 5.0 EAP.

Suggestions or should I just pick my battles when it comes to VS 2008?

Screenshot: My apologies, I could have sworn I added a screenshot to this question.

http://www.twitpic.com/z6bxj


The VS designer is not good at handling cases where your markup jumps between server-side and client-side script.
Sometimes adding <%=""%> at the top helps, as per this post: http://forums.asp.net/t/1384577.aspx. The VS designer also seems slow to pick up changes, re-parse and remove error squiggles.

In your case I think it's trying to parse that line as Javascript but it's obviously not. If you're nuts about removing the errors you would have to re-factor the code, eg generate the entire JS script as a server-side string and write it out.

I've learned to view error squiggles as advice only, and once the page is stable and working just ignore them.

0

精彩评论

暂无评论...
验证码 换一张
取 消