AxWebBrowser Control

ManojAlexander

New member
Joined
Dec 23, 2003
Messages
1
I have loaded Html page to a AxWebBrowser control .
And I can retrive all Tags and Contents of loaded HTML Documents from AxWebBrowsers Document object.
But I cant Insert Contents (Data or HTML Or Scripts) to the HTML Documents Dynamically from my Application as this Document Object is read Only.
Is there any way to Fill Data in a Input Box (eg- TextArea) from my Application....?
And I do Like to know the use of ExecWB() Method.. and Can I use this method to Run a Script Function in the HTML Document...?
 
make a reference to Microsoft mshtml controls ( project , add reference ) then , this should start you off....
Code:
    Dim doc As mshtml.HTMLDocument
    Dim em As mshtml.IHTMLElement

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AxWebBrowser1.Navigate("http://google.com")
    End Sub

    Private Sub AxWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles AxWebBrowser1.DocumentComplete
        doc = DirectCast(AxWebBrowser1.Document, mshtml.HTMLDocument)
        em = doc.getElementById("q") /// q is the textbox you use on googles search , your elements id would go here.
        em.setAttribute("value", "test123")
    End Sub
 
infact you can do this without a reference to mshtml , heres an example i knocked up which only requires the webbrowser...
Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AxWebBrowser1.Navigate("http://google.com")
    End Sub

    Private Sub AxWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles AxWebBrowser1.DocumentComplete
        Dim o() As Object = {"q"} /// googles textbox
        Dim v() As Object = {"value", "test"} /// the value to enter to it ( second item in array )
        Dim x As Object = AxWebBrowser1.Document.GetType.InvokeMember("getElementById", Reflection.BindingFlags.InvokeMethod, Nothing, AxWebBrowser1.Document, o)
        x.GetType.InvokeMember("setAttribute", Reflection.BindingFlags.InvokeMethod, Nothing, x, v)
    End Sub
 
Reading Element ID

Can you use this same procedure for reading the information from an element ID in a web page hosted in the WebBrowser control? If so, would you mind demonstrating any changes that may be required to the code? Thank you.
 
AxWebBrowser Controls ExecWB()

This property allows you to show/hide menus and toolbars of the object being displayed in the control! Sample:

webViewBOL.ExecWB(SHDocVw.OLECMDID.OLECMDID_HIDETOOLBARS, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT)

This command actually HIDES toolbars in a word document being displayed in a windows form!

Cheers!~
 
Back
Top