我是C#的新手并且自己搞乱了,现在,我一直在尝试创建一个可以在网页中发布一些参数并在获得的结果网页上做某事的WinForm。现在我已经在一个使用POST方法的页面上完成了这个,但我无法使用具有如下html代码的网页:
<form method="post" action="test.asp" name=FrontPage_Form1 onsubmit="return FrontPage_Form1_Validator(this)">
<div align="center"><center><p>
<input name="name" size="8" maxlength=8><font color="#faebd7">---
现在我不知道如何用HttpWebRequest实现这个“ONSUBMIT”..
这是我目前的代码:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://cbseresults.nic.in/aieee/cbseaieee.asp");
request.Method = "POST";
string r = "regno=" + rno.ToString();
Bytes = Encoding.UTF8.GetBytes(r);
request.ContentLength = Bytes.Length;
request.ContentType = "application/x-www-form-urlencoded";
RequestStream = request.GetRequestStream();
RequestStream.Write(Bytes, 0, Bytes.Length);
RequestStream.Close();
Response = (HttpWebResponse)request.GetResponse();
StreamReader ResponseStream = new StreamReader(Response.GetResponseStream(), Encoding.ASCII);
string Result = ResponseStream.ReadToEnd();
ResponseStream.Close();
但它不起作用,非常感谢任何帮助...