how to pass a razor value to a jquery function, in an mvc view

后端 未结 6 1363
耶瑟儿~
耶瑟儿~ 2020-12-09 02:31

So I\'m trying to pass a parameter to a javascript function using the razor \'@\' notation (in an MVC-4 View) but I\'m getting Syntax error: \"Unterminated string constant\"

6条回答
  •  隐瞒了意图╮
    2020-12-09 02:38

    To avoid this kind of issue, you may build all your js function call in c# code section.

    Instead of:

    
    

    Use:

    @{
      var assignFunctionCall = "AssignButtonClicked(" + item.ID + ")";
    }
    
    

提交回复
热议问题