0

I have a number of my own .js files containing javascript code in a MVC4 project in Visual Studio 2012. The intellisense does not work in these .js files and the error checking is showing spurious errors such as 'Too many characters in character literal' and 'a namespace cannot directly contain members such as field'.

I think what is happening is that it is not identifying the code as javascript (including the jquery files auto added by the mvc4 template). Possibly the file type .js is not associated to Javascript. I've tried Tools -> Optioins -> Text Editor -> File Extension & added js as Script Editor but that didn't work.

If I put a script block in a cshtml page it identifies my Javascript code perfectly but I need to separate my js into separate files.

Any help would be much appreciated :-)

1 Answer 1

3

It sounds like you set the Build Action to Compile, which treats it as C#.
Set it to Content instead.

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

1 Comment

Really not sure what happened here, I simply looked at my code three hours later and there was no problem. I think something must be setting the compile automatically. Strange. Thanks for your input.

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.