Reputation: 25
I am trying to call a C# method in my javascript code and also trying to pass parameter to it using razor syntax but not able to do it correctly. Below is my code:
function RecallNoFmatter(cellvalue) {
var value = @(Precall.S300FormatRecall(+cellvalue+));
return value;
}
I get this error message:
Compiler Error Message: CS0103: The name 'cellvalue' does not exist in the current context.
Can someone tell me the correct syntax of how to pass parameter in above?
Upvotes: 2
Views: 1515
Reputation: 245399
C# runs server-side. The @
code is running server-side before the script is delivered to the client and has no access to the JavaScript values.
Your JavaScript runs client-side and has no ability to call server-side methods.
If you want to expose server-side functionality to the client, you're going to have to use AJAX and provide some service for the client to call.
Upvotes: 6