3

有没有办法在使用 webbrowser 控件时获取字符串的值并将其传递给网页中的文本框?

4

3 回答 3

10
HtmlDocument doc = this.webBrowser1.Document;
doc.GetElementById("myId").SetAttribute("Value", "someValue");

试试这个

于 2009-10-21T04:59:29.240 回答
2

你可以这样做:

String newValue = "Sample Text";
HtmlElement txt = WebBrowser1.Document.GetElementById("ElementIdOnHtmlPage");
txt.SetAttribute("value",newValue);
于 2009-10-21T05:07:06.180 回答
1

您可以在 C# 中为 WebBrowser 控件执行浏览器自动化。

这是解释如何做到这一点的参考文章。

http://www.codeproject.com/KB/cs/mshtml_automation.aspx

于 2009-10-21T05:04:09.773 回答