Hi all..i make a program use javascript to call VB.Net function..but it doesn't work...can somebody help me to check this code...

Imports System.Runtime.InteropServices

<ComVisible(True)> _
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.ObjectForScripting = True
        WebBrowser1.DocumentText = "<Script language='JavaScript'>" & vbCrLf & _
                    "function callfunction() { " & vbCrLf & _
                    "window.external.cfunction();" & vbCrLf & _
                    "}" & vbCrLf & _
                    "</script>" & vbCrLf & _
                "<a href=# onclick='callfunction'>test</a>"
    End Sub

    Public Sub cfunction()
        MsgBox("test saja", MsgBoxStyle.ApplicationModal, ProductName)
        'Return 0
    End Sub
End Class

Change:
Webbrowser1.ObjectForScripting = true

to:
Webbrowser1.ObjectForScripting = Me

Greetz,
Marc

thanks buddy.. it works really better than other codes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.