Visual Studio 2010: force syntax highlighting / in

2019-09-10 15:44发布

问题:

in a web application i've some dynamic js files, with aspx extension; i would to benefit the syntax highlighting / intellisense support for javascript while editing, but Visual Studio does not recognize the file as javascript. Is there some way to force visual studio to threat a file with a custom "editing experience"?

回答1:

I am using a similar approach to what you are doing. I'm using Visual Studio 2013 and I can fool it by adding a <script> tag in a code block that is not executed:

<%@ page language="C#" autoeventwireup="false" codefile="Script.aspx.cs" EnableViewState="false" inherits="Script" StyleSheetTheme="" %>

<% if (false){ %> <script type="text/javascript"> <% }%>

... Javascript goes here

<% if(false){ %> </script> <% }%>