Question

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.

Was it helpful?

Solution 3

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

OTHER TIPS

Your javascript should look something like this:

function uploadAction::stateChanged( parms )
{
    // ...
    // implementation
    // ...
}

Note, that this is a static function declaration, assuming that you have an Active X object named 'uploadAction'. I know that this does work - we use it at my company.

The error message means that uploadAction does not support stateChanged property. Your javascript code looks correct, the problem seems to be with the object you are trying to attach an event handler to.

I'd suggest using the advanced event registration model outlined here.

uploadAction.addEventListener('stateChanged', upload_stateChanged, false);

note, you may need to interrogate your arguments for the upload_stateChanged method, as the first argument should be the event state. ex: upload_stateChanged(evt, sender) ...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top