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

萝らか妹 提交于 2019-12-01 09:03:13

问题


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?


回答1:


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

try this




回答2:


You can do something like this:

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



回答3:


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



来源:https://stackoverflow.com/questions/1598780/c-sharp-pass-string-to-textbox-in-web-page-using-the-webbrowser-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!