简体   繁体   English

如何在MVC4 Razor的字符串中使用@class

[英]how to use @class in a string with MVC4 Razor

I have an MVC4 Razor application where I need to construct a string in a javascript section containing @class. 我有一个MVC4 Razor应用程序,我需要在包含@class的javascript部分中构造一个字符串。 How can I escape to use that in the string? 如何逃避在字符串中使用它?

var S = 'select * from html where url=\"www.yahoo.com\" and xpath=\'\//div[contains('@class,\"techSpecsTable/\")]\' '

how do I escape @class? 我怎么逃避@class?

You can escape the @class by doing 你可以通过这样做来逃避@class

@@class

but I think you need to excape the ' 但我认为你需要逃避'

var S = 'select * from html where url=\"www.yahoo.com\" and xpath=\'\//div[contains(\'@class,\"techSpecsTable/\")]\' '

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM