简体   繁体   中英

DotNetBrowser set value of form

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.

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;
    //...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM