MVC: Use string variables of a view as parameter to a javascript function call
问题 How can I call a javascript function within a view(cshtml) and pass some string variables (defined in the view)to be used as parameters for the function call? Say the function javascriptFunction uses 2 parameter. I will usually call it as javascriptFunction('param1', 'param2') . But now I want to pass it some variables. string y = "this is a string" string x = "another" javascriptFunction(y, x) I have tried javascriptFunction(@y, @x), javascriptFunction('@y', '@x') but this does not work 回答1: