1

Does anyone know if the ASP.NET MVC 3 team have come out with any changes that will stop the Razor syntax highlighter in VS2010 showing so many errors when I embed JavaScript in my razor pages. My code seems to work but it is very confusing when it comes to me trying to debug. Surely by now they have some fixes so I don't have to look at green underlines and see strange synax error messages.

2 Answers 2

2

Some parts of Razor syntax work better than others inside javascript blocks - try

jsvar = "@(Model.SomeProperty)";

instead of

jsvar = "@Model.SomeProperty";
Sign up to request clarification or add additional context in comments.

Comments

2

I know that the general push is for the separation of code. Meaning, there is a strong push to keep your JavaScript in separate .js files, your CSS in separate .css files, and your views in their own files (separate from their controllers obviously).

I think that you should have relief from the green underlines and syntax messages if you put the JavaScript in separate files.

Additionally, there are a couple JavaScript extensions that you can add to Visual Studio to help with these regardless of where the JavaScript is located.

Comments

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.