C++技巧辅导:JS中对象转到c#对象方法
来源:优易学  2011-10-11 17:27:00   【优易学:中国教育考试门户网】   资料下载   IT书店
  <script type="text/javascript">
  var xmlHttp;
  function createXMLHttpRequest()
  {
  if (window.ActiveXObject)
  {
  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  else if (window.XMLHttpRequest)
  {
  xmlHttp = new XMLHttpRequest();
  }
  }
  //[{Name:"张可",Class:4},{Name:"李贵",Class:5}]
  function doJSON()
  {
  createXMLHttpRequest();
  xmlHttp.onreadystatechange=handleStateChange;
  xmlHttp.open("post","dojson.aspx",true);
  xmlHttp.setRequestHeader("content-type","application/x-www-form-urlencode");
  xmlHttp.send({Name:"张可",Class:4},{Name:"李贵",Class:5});
  }
  function handleStateChange()
  {
  if(xmlHttp.readyState == 4)
  {
  if(xmlHttp.status == 200)
  {
  alert("is ok!!!");
  }
  }
  }
  </script>
  c#
  protected void Page_Load(object sender, EventArgs e)
  {
  byte[] b = new byte[this.Request.InputStream.Length];
  this.Request.InputStream.Read(b, 0, b.Length);
  string s = System.Text.Encoding.Default.GetString(b);
  student s1 = (student)JavaScriptConvert.DeserializeObject(s, typeof(student));
  }
  public class student
  {
  public string Name
  {
  get{;}
  set{;}
  }
  public string Class
  {
  get{;}
  set{;}
  }
  };
  所需要组件下载http://james.newtonking.com/

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训