C# - 使用 webbrowser 控件将字符串传递到网页中的文本框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1598780/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C# - Pass string to textbox in web page using the webbrowser control
提问by user
Is there a way to take the value of a string and pass that to a textbox within a web page while using the webbrowser control?
有没有办法在使用 webbrowser 控件时获取字符串的值并将其传递给网页中的文本框?
采纳答案by Arsen Mkrtchyan
HtmlDocument doc = this.webBrowser1.Document;
doc.GetElementById("myId").SetAttribute("Value", "someValue");
try this
尝试这个
回答by this. __curious_geek
You can do the browser automation in C# for WebBrowser control.
您可以在 C# 中为 WebBrowser 控件执行浏览器自动化。
Here's the reference articleexplaining how you can do that.
回答by jerjer
You can do something like this:
你可以这样做:
String newValue = "Sample Text";
HtmlElement txt = WebBrowser1.Document.GetElementById("ElementIdOnHtmlPage");
txt.SetAttribute("value",newValue);