我在JavaScript中有一个变量,我想在我的C#代码中将它用作索引引用。如何将JavaScript变量转换为C#可以使用的内容?到目前为止,这是我有..将JavaScript转换为C#
@{
var selectedStockLocation = @Html.Raw(Json.Decode(document.getElementById("cbLocation " + id).value));
var currentLocation = Model.StockLocationBinData[selectedStockLocation];
}
谢谢!
请参阅http://stackoverflow.com/questions/9516293/how-to-access-a-javascript-variable-from-code-behind-in-asp-net/9516345#9516345 – 2012-03-01 14:26:07
javascript在哪里? javascript变量在哪里? – Oded 2012-03-01 14:26:37
你可以发布一些更多的代码,看看你想在View和你的控制器之间进行通信。 @AndreLoker:我认为这篇文章是关于如何在webforms中处理它。 – PraveenLearnsEveryday 2012-03-01 14:31:17