Use of a VB.NET enum in a window.external method call Options

P

Peter

Hi

Does anyone know if it's possible to for Javascript to reference an
enum in a Class that is assigned to a VB.NET Form's embedded browser
control using the ObjectForScripting property?

I define a Class as follows:

<System.Runtime.InteropServices.ComVisibleAttribute(True)> _
Public Class MyClass


Public Enum MyEnum
Enum1 = 1
Enum2 = 2
Enum3 = 3


End Enum


Public Sub MyMethod(Param1 as MyEnum)
<Code goes here>


End Sub


End Class


"MyClass" is then assigned to the browser control as follows:


Dim lMyClass as MyClass
Browser.ObjectForScripting = lMyClass


From my web page which runs inside Browser I want to make the
following call to the MyClass.MyMethod as follows:


function button_click()
{
window.external.MyMethod(MyEnum.Enum2)
}


However it seems the "MyEnum" is not recognised across the COM
interface between the browser and .NET. The "window.external.MyMethod
(MyEnum.Enum2) Javascript statement results in an "Object does not
support Automation" error message (or similar). If I change the
declaration to MyMethod to "MyMethod(Param1 as Integer)" and then use
the following Javascript statement it works fine:
"window.external.MyMethod(2)"


Can someone tell me if it's possible for Javascript to reference an
enum in a Class that is assigned to a VB.NET Form's embedded browser
control using the ObjectForScripting property?


Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top