namespace WindowsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://www.baidu.com");
} private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Document.Forms[0].Children["wd"].SetAttribute("value", "test");
}
}
}
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://www.baidu.com");
} private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Document.Forms[0].Children["wd"].SetAttribute("value", "test");
}
}
}
HtmlElement txtName = htmlDoc.All("member");
HtmlElement txtPass = htmlDoc.All["Password"];
HtmlElement btnLogin = htmlDoc.All["Enter"]; if (txtName == null || txtPass == null || btnLogin == null)
return; txtName.SetAttribute("value", "123456");
txtPass.SetAttribute("value", "123456");
btnLogin.InvokeMember("Click");
.NET 2.0 支持
webBrowser.Document.GetElementById()或者webBrowser.Document.GetElementByTagName()(Index)取得对象之后给它赋值.
总之研究一下webBrowser.Document.*的相关方法就可以了!