Search code examples
javascripteventsactivex

Javascript registering event to object


I have an activex object I loaded into an html page. I then use that activex object to create another object, but I need to register an event with the new object created. The object is expecting an event listener of a certain type.

I can load this same dll in c# and it will work fine. Code looks like this for c#.

upload = obj.constructUploadObj(uploadConfig);
upload.stateChanged += new UploadActionEvents_stateChangedEventHandler(upload_stateChanged);

In javascript I have similar code however I cannot get the event registered with the object.

uploadAction = obj.constructUploadObj(uploadConfig);
uploadAction.stateChanged = upload_stateChanged;

function upload_stateChanged(sender){
    writeLine("uploadState changed " + sender.getState());
}

I have enumerated some of the properties of the uploadAction object in javascript to ensure that it is actually created. When I try and register the event with uploadAction it throws an error saying "Object doesn't support this property or method."

To me it seems like its expecting a strongly typed event. Is there anyway to register the event similar to that of C# in javascript?

Thanks In Advance.


Solution

  • Found out from the company that these properties are not accessible through javascript. They will need to externalize them for use within javascript.