tags:

views:

117

answers:

3

How to access the elements within an in WebBrowser in C#.NET?

A: 

Generally, you can't. C# and .NET are typically used in frameworks like ASP.NET to produce the content that is consumed by the browser. This happens on the server-side.

If .NET is installed on the client, then you can host a Windows Forms control in an HTML document in Internet Explorer but this is very, very non-standard, and I'd advise heavily against doing so.

casperOne
@casper I think he is talking about the WebBrowser control for Winforms
Shoban
A: 

As far as I understand you can access the controls inside the webbroswer control using the following code

WebBrowser1.Document.GetElementById("controlId").

Is this what you are looking for?

Additionally this discussion in daniweb might be of some interest to you.

Shoban
I tried not help
Dmitry
What did you mean by it did not help? How did it not help you? I have a similar application and it works for me. Its not an iframe though
Shoban
A: 

try this

webBrowser1.Document.GetElementById("idName").SetAttribute("value") = "ddddd" ;
var stuff=webBrowser1.Document.GetElementById("idName").GetAttribute("attribute");

it works for me when I need to get/set control data and get any html element value

Luiscencio