System.Web.Script.Serialization.JavaScriptSerializer
这个可以转

解决方案 »

  1.   

    POST传值,不需要把html转化成C#代码,那样的话,如果表单的值特别多的话,处理起来就很麻烦了。楼主参考一下这个吧,和你的需求类似,从给一个页面,把值传给另外一个页面:
    http://blog.163.com/mas_lxw/blog/static/54015798201121773319921/
      

  2.   

    1.1问不大明白。<form id="compeleform" action="getput.aspx  method="post" onSubmit="return submitFun()">这里已经指定了调用submitfucn的js将html上的值post到服务端了。
    2.2问System.Web.Script.Serialization.JavaScriptSerializer 这个就可以将接收到的json反序列化。
      

  3.   

    象我找到这个,微信开发的, 可以直接程序化POST , 但是调我这个出错了,还在查原因   static string postWebReq(string postUrl, string paramData, Encoding dataEncode)
            {
                string ret = string.Empty;
                try
                {
                    byte[] byteArray = dataEncode.GetBytes(paramData);
                    HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(postUrl));
                    webReq.Method = "POST";
                    webReq.ContentType = "application/x-www-form-urlencoded";
                    webReq.ContentLength = byteArray.Length;                Stream newStream = webReq.GetRequestStream();
                    newStream.Write(byteArray, 0, byteArray.Length);
                    newStream.Close();                HttpWebResponse reponse = (HttpWebResponse)webReq.GetResponse();
                    StreamReader sr = new StreamReader(reponse.GetResponseStream(), Encoding.Default);
                    ret = sr.ReadToEnd();                sr.Close();
                    reponse.Close();
                    newStream.Close();
                }
                catch (Exception ex)
                {            }
                return ret;
            }