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?
DLueckAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
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
0
RejojohnyCommented:
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
0
DLueckAuthor Commented:
I solved my answer.....

I had to change add a literal control on the web page :
<asp:Literal ID="VitalsLiteral" runat="server"></asp:Literal>

Than in the page load, i added the following code..
...
        get monitor information and setting from database
...
        if (MonitorType.ToUpper() == "PORT")
        {
            // load object onto page
            strObject = "<object name='VitalsControl' ";
            strObject += "CLASSID='CLSID:A176D37E-5B0C-4443-90BA-EAAA4F885B41' ";
            strObject += "codebase='vitals\\cab\\cMoreVitalsNet.CAB#version=1,0,0,17' ";
            strObject += "height='20' ";
            strObject += "width='120' ";
            strObject += "viewastext id='VitalsControlNet'>";
            strObject += "</OBJECT>";
        }
        else
        {
            // initialzie parameter variables
            string LogIntervalTime = string.Empty;
            string LogEvents = string.Empty;
            string StartUpDelay = string.Empty;

            // get the monitor settings from the database
            foreach (VMGetVMTypeAndSettings VMTS in VM_GetVMTypeAndSettings)
            {
                switch (VMTS.SettingID.ToUpper())
                {
                    case "NINTERVAL":
                        LogIntervalTime = VMTS.DataValue;
                        break;
                    case "DEBUG_MODE":
                        LogEvents = VMTS.DataValue;
                        break;
                    case "STARTUP_DELAY":
                        StartUpDelay = VMTS.DataValue;
                        break;
                }
            }

            // load object onto page
            strObject = "<OBJECT ID='CGUSBVitals1' ";
            strObject += "WIDTH=120 ";
            strObject += "HEIGHT=20 ";
            strObject += "CLASSID='CLSID:DD698DA9-9D32-4F12-8D7C-789E129BB367' ";
            strObject += "codebase='vitals\\cab\\MCGUSBCab.CAB#version=1,0,0,1'> ";
            strObject += "<PARAM NAME='_Version' VALUE='65536'>";
            strObject += "<PARAM NAME='_ExtentX' VALUE='2455'>";
            strObject += "<PARAM NAME='_ExtentY' VALUE='709'>";
            strObject += "<PARAM NAME='_StockProps' VALUE='0'>";
            strObject += "<PARAM NAME='MonitorName' VALUE='" + MonitorName + "'>";
            strObject += "<PARAM NAME='LogIntervalTime' VALUE='" + LogIntervalTime + "'>";
            strObject += "<PARAM NAME='LogEvents' VALUE='" + LogEvents + "'>";
            strObject += "<PARAM NAME='StartUpDelay' VALUE='" + StartUpDelay + "'>";
            strObject += "<PARAM NAME='Caption' VALUE='" + MonitorName + "'>";
            strObject += "</OBJECT>";
        }
        this.VitalsLiteral.Text = strObject;
    }

==end code===

The correct object (activex) comes up each time I select a different type of monitor (serial vs usb)

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

DLueckAuthor Commented:
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.
0
RejojohnyCommented:
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 ..
0
Vee_ModCommented:
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.