Visual Studio confused by server code inside javascript

前端 未结 7 928
[愿得一人]
[愿得一人] 2021-01-11 19:00

I ran into an annoying problem: the following code gives a warning in Visual Studio.



        
7条回答
  •  悲哀的现实
    2021-01-11 19:40

    I believe that you ask from visual studio to understand too difficult thinks.

    How visual studio can know what is inside the string that you pass ?, its parameters, its more code, what it is ???.... How VS can know what it is so can tread them that way ?

    So they decide that everything on script tag there must be JavaScript.

    My opinion is that if you won to avoid this error, Write render this JavaScript on code behind and not inside aspx page.

    string cPlaceMeOnScript = ""
    

    and use any method to place this string on the start of your script.

提交回复
热议问题