简体   繁体   中英

Not able to call ActiveX method on button click at client side in a Vsual WebGui application

I am creating a project in visual WebGui, On loading of first page i have taken a ActiveXBox and installed it to the system.

Now I want to access the methods available in the ActiveX control at client side which is already installed in the client machine. Problem is that the code is executed at server side and the code works for server.

What should i do so that the code will be executed for the client machine.

Thanks

We can achieve this in this way. As the activex control is registered in the com after installing. we can call the methods inside it.

Type ComType;
object ComObject;
Guid myGuid1 = new Guid("2ABF5C37-ABC3-4600-8115-4F7E6F64C765");
ComType = Type.GetTypeFromCLSID(myGuid1);
ComObject = Activator.CreateInstance(ComType);

object[] args = new object[1];
args[0] = arg1;

ComType.InvokeMember("Your Method Name", BindingFlags.InvokeMethod, null, ComObject, args);

@Amish Kumar,

The code you posted is a server-side code, which for a Visual WebGui web application means, that the code will run at the webserver only, provided the ActiveX control has been installed on the server. This may work for you (although not recommended) if you run your web application using your local host as your IIS webserver, but when the webserver is a remote machine, this code will not affect the client.

For Visual WebGui Web applications, you have chosen the correct hosting control, ActiveXBox, which will add the ActiveX control to the client's browser. To control it, you usually set "parameters" on the ActiveXBox control, which will then update/contact the ActiveX control it is hosting.

A fairly good example of how it works can be found in one of Visual WebGui's forum threads here (controlling a media player ActiveX control), and more information and sample can be found here .

Palli

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM