C++技巧:JS中对象转到c#对象方法 |
|
www.nanhushi.com 佚名 不详 |
<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/ 考试大等级站收集整理!
|
|
|
文章录入:杜斌 责任编辑:杜斌 |
|
上一篇文章: 求2个数据:五位数=2*四位数,9个数互不相同 下一篇文章: C++基础(编译最新的snmp++v3.2.23) |
【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |
|
|