DotNetBrowser set value of form

389 Views Asked by At

I'm trying to set value of form in DotNetBrowser, but to get this form I have to use

var b = browserView.Browser.GetDocument().GetElementsByTagName("span")[1];

because ID's of forms aren't unique. The problem is that returns me

DotNetBrowser.DOM.DOMNode

and to make a usage from example that provides DotNetBrowser link. I need

DotNetBrowser.DOM.DOMInputElement

which I have no idea how to convert into.

1

There are 1 best solutions below

0
On BEST ANSWER

The span DOM node can be safely casted to DOMElement:

var b = browserView1.Browser.GetDocument().GetElementsByTagName("span")[1] as DOMElement;

You can also use a DOMNode.NodeType property to check the node type and then perform a safe cast:

if (b.NodeType == DOMNodeType.ElementNode) {
    DOMElement element = b as DOMElement;
    //...
}