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

Discussion in 'ASP .Net' started by Peter, Jul 5, 2009.

  1. Peter

    Peter Guest

    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
     
    Peter, Jul 5, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. -

    enum within an enum

    -, Jun 12, 2005, in forum: Java
    Replies:
    6
    Views:
    568
  2. Jerminia
    Replies:
    3
    Views:
    641
    Roedy Green
    Oct 7, 2005
  3. Ernst Murnleitner

    How to enum an enum?

    Ernst Murnleitner, Nov 12, 2003, in forum: C++
    Replies:
    5
    Views:
    485
    Rolf Magnus
    Nov 13, 2003
  4. grbgooglefan
    Replies:
    4
    Views:
    458
    Kenny McCormack
    Jan 30, 2008
  5. grbgooglefan
    Replies:
    0
    Views:
    411
    grbgooglefan
    Jan 30, 2008
Loading...

Share This Page