Get element from web browser control in windows application


I required to get element from web browser control and also wanted to set its value.

I searched out on google and got some solutions , so i’d like to share with you guys.

Here is a code snippet,

private void wbBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser wb = (WebBrowser)sender;

wb.Document.GetElementById("txtCity").SetAttribute("value", "myValue");
wb.Document.GetElementById("txtName").SetAttribute("value", "myValue");
wb.Document.GetElementById("btnSave").InvokeMember("click");
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: