0

Recently I installed visual studio 2012. I converted my project in the log it seems to be fine, No errors. When I look in the code in the javascript at the end of the sentence he marks the ; red and gives the error: "syntax error". Weirdly of all the line of code still works but I only get this error in VS2012 and not in VS2008. The projects still builds because this is javascript. Any idea why this is marked as an error in VS2012?

<link id="Link1" rel="stylesheet" runat="server" media="screen" href="Styles/jquery-ui.css" />
<!-- load jQuery and tablesorter scripts -->
<script type="text/javascript" src="JS/jquery-1.9.1.js"></script>
<script type="text/javascript" src="JS/jquery-ui.js"></script>
<script type="text/javascript" src="JS/jquery.json-2.2.min.js"></script>
<script type="text/javascript">
        var publicationTableSiteIDs = <%= getJsonSiteIDs() %>;
        var publicationTableCountries = <%= getJsonCountries() %>;


public string getJsonSiteIDs()
        {   //list to javascript for autocorrect on site id's
            return (new JavaScriptSerializer()).Serialize(siteIdsList.Distinct().ToList());
        }

        public string getJsonCountries()
        {   //list to javascript for autocorrect on countries
            return (new JavaScriptSerializer()).Serialize(countryList.Distinct().ToList());
        }

1 Answer 1

1

Visual Studio's editor is trying to parse your interpolated server-side code as Javascript, resulting in a syntax error.

At runtime, the server-side code is properly executed on the server, returning valid Javascript (unless your data has U+2028), so it works fine.

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

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.