我的任务:在网站(我的大学网站)中,当使用我的 c#(windows 或 web 应用程序)代码自动生成结果时,卷号将增加,结果将存储在我的数据库中。我需要为文本框提供值我的代码中的大学网站。,我能够找到文本框的 html 输入标签名称(regno)。问题是,HTML 页面正在使用带有返回值的 onSubmit 事件(以验证在文本框中输入的卷号)它被重定向到另一个页面(输出结果页面)。我该怎么做我为 onSubmit 方法(来自我的 C# 代码)提供值,以便它返回“true”并且我应该能够从输出页面中检索值还有.请帮助,我不知道从哪里开始,或者如何开始。
<SCRIPT language=JavaScript>
<!--
function checkregno()
{
if (window.RegExp)
{
strval=document.forms["result"]["regno"].value;
reExp=new RegExp("^\\d{14}$");
}
function dele()
{
document.result.action="http://www.annauniv.edu";
document.result.submit();
}
//-->
</SCRIPT>
<META content="MSHTML 6.00.2800.1491" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=gray
onload="javascript:document.forms['result']['regno'].focus()">
<FORM name=result onSubmit="return checkregno();" action=/cgi-bin/result/resgrbarchpg.pl method=post>
<INPUT maxLength=14 size=14 name=regno>
<INPUT onClick="return checkregno();" type=submit value=Submit>
<INPUT type=reset value=Clear name=clear>
我用来检索页面源的代码是:静态字符串 GetHtmlPage(string strURL) {
String strResult;
WebResponse objResponse;
WebRequest objRequest = HttpWebRequest.Create(strURL);
objResponse = objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
strResult = sr.ReadToEnd();
sr.Close();
}
return strResult;
}
protected void Button1_Click(object sender, EventArgs e)
{
string tablecode = null;
String TheUrl = "http://www.annauniv.edu/1234566789/grbarchpg.html? regno=23010205001";
string response = GetHtmlPage(TheUrl);
tablecode = response;
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(@tablecode);
TextBox1.Text = tablecode;
}