高分求解

flers 2005-01-15 05:02:17
mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)this.WebBrowser.Document;
mshtml.IHTMLInputElement input = (mshtml.IHTMLInputElement)doc.all.item("txt_UserName", 0);
mshtml.IHTMLInputElement input1 = (mshtml.IHTMLInputElement)doc.all.item("txt_Password", 0);
input.value = "admin";
input1.value = "321";
mshtml.IHTMLFormElement form1=(mshtml.IHTMLFormElement)doc.all.item("Form1",0);
form1.method="post";
form1.action="http://192.168.1.10/wygl_asp/default.aspx";
form1.submit();//提交
提交form1时,webBrowser只是刷了一下,并没有执行登录,如何post数据给我的网站上并执行提交?
...全文
151 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
nga96 2005-01-16
  • 打赏
  • 举报
回复
学习,UP
aijing 2005-01-15
  • 打赏
  • 举报
回复
studying
flers 2005-01-15
  • 打赏
  • 举报
回复
谢谢 cnhgj(戏子) (我们可不可以不勇敢) 这个功能已实现
在winform中只能用webbrowser吗?有别的更好方法吗?直接post数据过去,不用这个控件。
smallMage 2005-01-15
  • 打赏
  • 举报
回复
学习…
luqixing 2005-01-15
  • 打赏
  • 举报
回复
学习
cnhgj 2005-01-15
  • 打赏
  • 举报
回复
有些并不是你提交submit就可以,特别是.aspx的。。以CSDN的登录为例


private void button1_Click(object sender, System.EventArgs e)
{
object n = null;
axWebBrowser1.Navigate("http://www.csdn.net/member/UserLogin.aspx", ref n, ref n, ref n, ref n);
}
private void button2_Click(object sender, System.EventArgs e)
{
mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)this.axWebBrowser1.Document;
mshtml.IHTMLInputElement input = (mshtml.IHTMLInputElement)doc.all.item("CSDNUserLogin_tb_UserName", 0);
mshtml.IHTMLInputElement input1 = (mshtml.IHTMLInputElement)doc.all.item("CSDNUserLogin_tb_Password", 0);
mshtml.IHTMLInputElement input2 = (mshtml.IHTMLInputElement)doc.all.item("CSDNUserLogin_tb_ExPwd", 0);
input.value = "admin";
input1.value = "321";
input2.value = "123456";
//mshtml.IHTMLFormElement form1=(mshtml.IHTMLFormElement)doc.all.item("Form1",0);
//form1.method="post";
//form1.action="http://www.csdn.net/member/UserLogin.aspx";
//form1.submit();
mshtml.IHTMLElement img = (mshtml.IHTMLElement)doc.all.item("CSDNUserLogin_Image_Login",0);
img.click();
}

它的登陆按纽是一个image,你直接模拟触发这个image的点击就可以了
LoveCherry 2005-01-15
  • 打赏
  • 举报
回复
mark

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧