c# - How to get the value of an input box of the webbrowser control in WPF? -


i added microsoft.mshtml reference project , came far:

        mshtml.ihtmldocument2 document = (mshtml.ihtmldocument2)webbrowser.document;         string username = document.all["username"].getattribute("value"); 

but 2nd line doesn't work. says

"error cs0021: cannot apply indexing [] expression of type 'mshtml.ihtmlelementcollection'"

when hovering on "all". how access elements in all?

try this:

var document = (ihtmldocument3) webbrowser.document; var value =     document.getelementsbyname("username")             .oftype<ihtmlelement>()             .select(element => element.getattribute("value"))             .firstordefault(); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -