NateShoffner
NateShoffner

Reputation: 16829

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

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?

Upvotes: 3

Views: 33426

Answers (3)

jerjer
jerjer

Reputation: 8760

You can do something like this:

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

Upvotes: 2

this. __curious_geek
this. __curious_geek

Reputation: 43207

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

Upvotes: 1

Arsen Mkrtchyan
Arsen Mkrtchyan

Reputation: 50712

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

try this

Upvotes: 10

Related Questions