日期:2014-05-17  浏览次数:20756 次

麻烦帮我看看哪里出错
下面是一个浏览器,实现到HTTP://onlinefamily.norton.com 那里自动填写不准浏览的网站,请帮我看看哪里错了,按了BUTTON没反应,我是VS 2005

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace autofillform
{
  public partial class Form1 : Form
  {
  public Form1()
  {
  InitializeComponent();
  }

  private void Form1_Load(object sender, EventArgs e)
  {
  webBrowser1.Navigate("http://onlinefamily.norton.com");
  }

  private void button1_Click(object sender, EventArgs e)
  {
  HtmlElement element = webBrowser1.Document.GetElementById("newBlockUrl");
  element.SetAttribute("value", "WWW.163.COM");
  webBrowser1.Document.All["blockListBtn"].InvokeMember("Click");



  }
  }
}

http://onlinefamily.norton.com 设置的屏蔽网站的HTML
<label for="newBlockUrl" class="" style="text-align: left; padding-left: 10px; width: 100%; padding-bottom: 6px;">输入网站</label>
<input class="fs_inpleft" id="newBlockUrl" name="newBlockUrl" autocomplete="off" style="width: 240px;" maxlength="100" type="text">

<button id="blockListBtn" type="button" class="btn-yellow-small" onclick="thisPage.addToBlockList(); return false;" style="float: right; margin-right: 10px;">




------解决方案--------------------
重新在界面上双击 Button 让它自动产生后台事件
------解决方案--------------------
你要先分析网页的格式和他的控件,然后再给值
------解决方案--------------------
这应该是正常登录后才能操作的页面,而你没有登录.
------解决方案--------------------
点击button时确保webbrowser已经加载完毕,没反应看看能否触发button的click,如果不触发就是没有关联上事件