日期:2014-05-17  浏览次数:20493 次

请教高手!!!asp.net后台接收jquery传数组值
前台代码:
<div overflow-y:scroll; style="padding-top:10px;padding-left:50px;">
<ul id="tree" class="tree" style="width:300px; border:1px solid #898c95; height:480px; overflow:auto;"></ul>
</div>
  <br />
  <div style="width:300px; padding-left:100px;"><asp:Button CssClass="submit" BorderColor="#6699cc" 
  BorderWidth="1px" Width="84px" ID="Button1" runat="server" Text="确定" 
  onclick="Button1_Click" />
  <asp:Button CssClass="submit" BorderColor="#6699cc" BorderWidth="1px" Width="84px" ID="Button2" runat="server" Text="取消" OnClientClick="javascript:window.close();"
 />
  <asp:Button CssClass="submit" BorderColor="#6699cc" BorderWidth="1px" Width="84px" ID="Button3" runat="server" Text="帮助" />
  <asp:HiddenField ID="permi" runat="server" />
  </div>
   
  <script type="text/javascript">
var zTree;
var demoIframe;

var setting = {
checkable:true,
isSimpleData: true,
treeNodeKey: "Id",
treeNodeParentKey: "PId",
nameCol: "Name",
showLine: true,
root: {
isRoot: true,
nodes: []
}
};
zNodes = [<% = NodesData %>];

$(document).ready(function() {
zTree = $("#tree").zTree(setting, zNodes);

$("#Button1").click(function(){
  var nodes = zTree.getCheckedNodes();
  //$("#<% =permi %>").val(nodes);
  $("#permi").attr("value",nodes);
  for(x in nodes){
  alert(nodes[x]["funcid"]);
  }
  });
  });
</script>

后台代码:

  protected void Button1_Click(object sender, EventArgs e)
  {
  //Response.Write(permission);
  //Response.ContentType = "application/json";
  string permission = this.permi.Value;
  Response.Write(permission); 
  Response.End();
  }

输出的结果总是:[object Object],[object Object],[object Object]

  我是新手,不知道该怎么传这个nodes的值到后台,快急死了,麻烦高手给指点一下,再次谢谢了!!!!!

------解决方案--------------------
<html>
<head></head>
<script src="js/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
function getData() {
var array = [{ a: 1, b: 2 }, { a: 1, b: 2}];
$("#permi").val(array);
alert($("#permi").val());
}
$(document).ready(function() {
$("#Button1").click(function() {
getData();
});
});
</script>
<body>

<form id="form1" runat="server" >
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>