Link to home
Start Free TrialLog in
Avatar of DLueck
DLueck

asked on

How to create a object at run time?

I searched the web and found some answer.  however most were unclear.

I need to create an object (activex control) on the fly based up what type of monitor the users has choosen. User choice is stored in a database.  Pseudo coded would look soemthing like this

If (MonitorType == "SERIAL")
{
 createobject  name="m1Control" CLASSID="1345677854253124321s"
                        codebase="m1control.CAB#version=1,0,0,17" height="20" width="120"
                        viewastext id="m1Control">
}
else
{
 createobject  name="M2Control" CLASSID=890749587495812749057194"
                        height="20" width="120" viewastext id="M2Control">
}

The first activex is seldom change (but we must support) is written in VB.  Second activex control is new and written in VC++.

Question is what are the command(s) to do this on the page load event?  is this possible?
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Hmmm...

It might be possible to define both the ActiveX controls in the HTML, and then toggle the visibility.  

I am curious what these ActiveX controls do?

Bob
you can dynamically render scripts to the generated page using page.clientscript.registerclientscriptblock .. you can do this on page load .. check the condition and render the code to create the activex control required ..

>>Second activex control is new and written in VC++.
do note that only COM activex controls will work on a web page and that too by default on IE (depending on the security settings) .. for other browsers, the user might need some plugins ..

Rejo
ASKER CERTIFIED SOLUTION
Avatar of DLueck
DLueck

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DLueck
DLueck

ASKER

Bob,

The activexes request/get data from a patient vitals monitor (blood pressure, heart rate, O2 percentage).

Alot of the monitors are connect to the serial port.  However the new ones coming out are starting to be connect by tghe usb port.  

So we decide to leave the old one alone (serial port) and make a new one for all the usb type monitors.

In the database I store the monitor type (comm/usb).  Based upon the monitor type, that activex control needed to be loaded onto the web page.

hope that answers your question.
i thought that the sugestion i made was similar to the final approach taken .. the difference been using a literal control instead of using registerclientscriptblock ..
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator