【发布时间】:2012-07-24 22:08:59
【问题描述】:
我需要将一个 js 多维数组(在编译时不知道维度)传递给我在 c# 中的代码隐藏,我已通过以下方式完成此操作:
var AdjustItems = ""; //My string variable to store the array separated with '|' and '-'
for (var i = 0; i < adjusts.length; i++) { //adjusts is my js array
AdjustItems += adjusts[i].Motive + '|' + adjusts[i].Amount.toFixed(2).toString() + '-';
}
if (AdjustItems != "") {
AdjustItems = AdjustItems.substring(0, AdjustItems.length - 1);
}
g('arrAdjust').value = AdjustItems; //arrAdjust is my hidden input.
有没有另一种方法可以让我得到数组,就像一个数组,而不是像 c# 中的一个字符串?
【问题讨论】:
标签: c# javascript code-behind