Uncaught SyntaxError: Invalid or unexpected token

后端 未结 3 439
野趣味
野趣味 2020-12-16 09:14

I have a razor syntax like this:

   foreach(var item in model)
 {
6/16/2016 2:02:29 A         


        
3条回答
  •  温柔的废话
    2020-12-16 10:06

    I also had an issue with multiline strings in this scenario. @Iman's backtick(`) solution worked great in the modern browsers but caused an invalid character error in Internet Explorer. I had to use the following:

    '@item.MultiLineString.Replace(Environment.NewLine, "
    ")'

    Then I had to put the carriage returns back again in the js function. Had to use RegEx to handle multiple carriage returns.

    // This will work for the following:
    // "hello\nworld"
    // "hello
    world" // "hello
    world" $("#MyTextArea").val(multiLineString.replace(/\n|/gi, "\r"));

提交回复
热议问题