You can't access JS variables directly from C#, because JS is client-side and C# is server-side. You can make a controller action and make an AJAX request to it with those parameters. Like this:
JS:
var id;
var dataToEvaluate;
jQuery.ajax({
type: 'POST',
url: 'SomeController/SomeAction',
data: { id: id, dataToEvaluate: dataToEvaluate },
success: function(data) {
// do what you have to do with the result of the action
}
});
controller:
public ActionResult SomeAction(string id, string dataToEvaluate)
{
// some processing here
return <probably a JsonResult or something that fits your needs>
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…