views:

870

answers:

3

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?

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

try this

ArsenMkrt
Thanks. Another tiny related question. How would I press a button within a webpage as well?
Nate Shoffner
invoke click like this..webBrowser1.Document.GetElementById("myBtn").InvokeMember("click");
ArsenMkrt
Whoops, meant to update this. I got it shortly after I asked. Thanks for all your help.
Nate Shoffner
A: 

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%5Fautomation.aspx

this. __curious_geek
+1  A: 

You can do something like this:

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