4

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 VS2k8 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

3
  • Can you show an example screenshot? Commented Jan 22, 2010 at 6:39
  • I started ignoring script squiggles long ago. I didn't even know there was an intellisense hotfix... Commented Jan 22, 2010 at 6:51
  • Screenshot added, my apologies. Commented Jan 22, 2010 at 6:58

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the advice. I was worried I was being a little too OCD about it :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.