Escaping JavaScript string literals in views

前端 未结 4 2139
栀梦
栀梦 2020-12-15 16:20

Is there a utility function for escaping JavaScript in ASP.NET MVC views? I often need to init a little snippet of JavaScript using some values from the view; for instance I

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-15 16:37

    In MVC 5 using Razor templates, the following is possible:

    
    

提交回复
热议问题