Search code examples
javascriptasp.net-mvcasp.net-mvc-4razoryql

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. 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?


Solution

  • You can escape the @class by doing

    @@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/\")]\' '