简体   繁体   中英

C# - Pass string to textbox in web page using the webbrowser control

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

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

try this

You can do something like this:

String newValue = "Sample Text";
HtmlElement txt = WebBrowser1.Document.GetElementById("ElementIdOnHtmlPage");
txt.SetAttribute("value",newValue);

You can do the browser automation in C# for WebBrowser control.

Here's the reference article explaining how you can do that.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM