DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Tue, 14 Aug 2007 07:48:01 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Eugene
          2    Alvin Bruney [MVP] some guy without an email address
                 3    Eugene
          4    Eugene


javascript, new ActiveXObject() and events   
Hello,
I have an ActiveX object with events, and I need to get notifications of 
these events in javascript script on asp.net web page.
The mentioned above ActiveX is a standard ATL com object implementing event 
interface:
dispinterface _MyEvents
{
	properties:
	methods:
	[id(1), helpstring("method MyEvent")] void MyEvent([out]BSTR aData);
};

Is it possible to subscribe to that event when the object is dynamically 
created with "var obj = new ActiveXObject("...")"? There's a lot of info 
about events when object is embedded into the page, but I can't find any 
decent info about events of dynamically created objects.

Thanks in advance for any help.
Date:Tue, 14 Aug 2007 07:48:01 -0700   Author:  

Re: javascript, new ActiveXObject() and events   

> about events when object is embedded into the page, but I can't find any
> decent info about events of dynamically created objects.


It follows the same pattern. You need to do a couple of things:
    Make sure IIS is configured correctly.
    Make sure the ActiveX control supports eventing - delegates and events 
are wired correctly for .net usercontrols.
    make sure the assembly is COM visible.
For unmanaged controls, this should all be done already so you can skip it.

If all the plumbing is setup correctly, you'll need to map the script from 
the client like so - assuming ClickEvent is an event in the activex control:

<script for=myControl1 event="ClickEvent(a,b)" language="javascript">
function myControl1::ClickEvent(a,b)

{

alert('Events are firing in Internet Explorer with co-ordinate: ' + a);

}

</script>

For dynamic controls, simply write out the script into the body of the html 
document. The end result for both process should be the fully formed script 
tag in the page when you view the html source.

That's about it. If the control is a managed user control embedded in a web 
form, you will need two more things:
1. Configure CAS for the application.
2. In script, tell IIS where to find the control roughly:
<OBJECT id="myControl1" name="myControl1" 
classid=http://server.com/ActiveX.dll#ActiveX.POCUserControl1> </OBJECT>


-- 
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET - MS Press
Professional VSTO 2005 - Wrox/Wiley
OWC Black Book www.lulu.com/owc

"Eugene"  wrote in message 
news:2C65DFC8-3FAF-48B7-9830-A3DAB732F4FF@microsoft.com...

> Hello,
> I have an ActiveX object with events, and I need to get notifications of
> these events in javascript script on asp.net web page.
> The mentioned above ActiveX is a standard ATL com object implementing 
> event
> interface:
> dispinterface _MyEvents
> {
> properties:
> methods:
> [id(1), helpstring("method MyEvent")] void MyEvent([out]BSTR aData);
> };
>
> Is it possible to subscribe to that event when the object is dynamically
> created with "var obj = new ActiveXObject("...")"? There's a lot of info
> about events when object is embedded into the page, but I can't find any
> decent info about events of dynamically created objects.
>
> Thanks in advance for any help. 
Date:Tue, 14 Aug 2007 19:27:30 -0400   Author:  

Re: javascript, new ActiveXObject() and events   
"Alvin Bruney [MVP]" wrote:


> <script for=myControl1 event="ClickEvent(a,b)" language="javascript">
> function myControl1::ClickEvent(a,b)
> 
> {
> 
> alert('Events are firing in Internet Explorer with co-ordinate: ' + a);
> 
> }
> 
> </script>
> 

That doesn't seem to work, as I have just a variable named MyObj but not an 
object with ID="MyObj". 

my javascript code:

var MyObj;

function PageLoad()
{
    try
    {
        MyObj = new ActiveXObject("MyLib.MyObject");  
        MyObj.Open(1);
    }
    catch (e)
    {
        alert(e);
    }
}

function PageUnLoad()
{
    try
    {
        if (MyObj.IsActive)
        {
            ScanApp.Close();
        }
        MyObj = null;
    }
    catch (e)
    {
        alert(e);
    } 
}


So when I add "function MyObj::OnBarcodeRead(aBarcode){  alert(aBarcode); }" 
the outcome is  predictable "Error: Object expected".

What I need is a mechanism like Advise to bind a javascript function to COM 
object event.
Date:Wed, 15 Aug 2007 00:30:01 -0700   Author:  

RE: javascript, new ActiveXObject() and events   
Well, it seems like there's no way of usingstandard events with the objects 
created by "new ActiveXObject" technique.

It's still possible to call javascript methods from ActiveX using 
IDispatch.Invoke supplied via ole object properties, f.e.  like Microsoft 
does in their XMLHTTP object. It  does essentially what I wanted to do.
Date:Wed, 15 Aug 2007 06:50:04 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us