Visual Studio confused by server code inside javascript

前端 未结 7 927
[愿得一人]
[愿得一人] 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:57

    The approach you're taking is not a particularly sturdy one. Obviously it wouldn't work if you wanted to move your Javascript code to a separate file in order to improve your page load times....

    You're better off using hidden form fields to move data from the server to client script. Alternatively, you can build the variable setter JS code programmatically by doing a bunch of string concatenation, then using the ClientScriptManager.RegisterClientScriptBlock() method to inject it into the output.

    0 讨论(0)
提交回复
热议问题