private void button1_Click(object sender, EventArgs e)
{
System.Windows.Forms.HtmlDocument document = this.webBrowser1.Document;
if (document != null)
{
document.All["logname"].SetAttribute("Value", "用户名"); //用户名
document.All["originalLogpasswd"].SetAttribute("Value", "密码"); //密码
document.All["dologin"].RaiseEvent("onClick"); //登录按钮的click事件
document.All["formRegStep1Main"].InvokeMember("submit"); //提交表单
}
}
像你上面那样写 只是return 出去了 if (){} 它还是会执行 if 外面的 若这样写 就不会报错了