Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

issues with using activex component on web form

  Asked By: Charlie    Date: Jul 02    Category: Asp.net    Views: 2722

I have created a reference to a 3rd party activex control. I have
added it to my components tab. I can successfully drag and drop the
control onto the web form and have it display properly on the
browser....my issue comes in when I try to actually reference that
object from the code-behind page.

For testing, I have created a button so that when the button is
clicked a new item is added to the one of the collections of the

When I try to do this from the code-behind with the "button.click"
event handler, it says that the name of the instance of the object is
not declared.

When I try to handle this on the client side, it totally seems to
bypass my script.

.aspx code*******

<%@ Import namespace = "scheduler" %>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="PBISched.aspx.vb" Inherits="PatientApp.PBISched"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<META content="Microsoft Visual Studio.NET 7.0"
<META content="Visual Basic 7.0" name="CODE_LANGUAGE">
<META content="JavaScript"
<SCRIPT language="javascript"

function pbi_ondataavailable() {

<SCRIPT language="javascript" event="ondataavailable"
return pbi_ondataavailable()
<SCRIPT language="vb" for="pbi" >

'********** next line is the one that I am hoping to get working******
Call pbi.rooms.Add("Room1")

<FORM id="Form1" method="post" runat="server">
<INPUT type="submit" value="Submit">
<asp:Button id="Button1" runat="server"
<OBJECT id="pbi" style="Z-INDEX: 101; LEFT:
95px; WIDTH: 521px; POSITION: absolute; TOP: 59px; HEIGHT: 175px"
classid="clsid:CB93D4CA-F746-11D2-9118-00A0241E587F" name="pbi">

*******code behind

Public Class PBISched
Inherits System.Web.UI.Page
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
'Do not modify it using the code editor.


End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click

'************** HERE it doesnt recognize pbi *****************
Call pbi.rooms.Add("Room1")

End Sub
End Class



2 Answers Found

Answer #1    Answered By: Neil Turner     Answered On: Jul 02

You may want to cross post to:



lots of client  Experts there. I never did a lot of Active-X except for the "assistants" and "remote scripting" so I can't help you on this one and others on the list don't seem to be helping you fast enough either so maybe the client experts there can help.

Answer #2    Answered By: Katrina Edwards     Answered On: Jul 02

I am interested in this ... I like ActiveX controls ... but looking at your code  you would seem to know more than I.

Will try this out myself, but first thoughts are ::

<SCRIPT language="vb" for="pbi" >
'********** next line  is the one that I am hoping to get working******
Call pbi.rooms.Add("Room1")

should work ... as all that has happened at this point is that the ActiveX should have been downloaded client  side by the server. What i can suggest is that that snippet is above the actual embedded object  and jscript runs as loads so it doesn't know about your ActiveX at that point. Move script  referencing the ActiveX to below where the object exists. I think ?

else add a button  to do it on a click  ( that way the page  has time to coplete downloading)

<SCRIPT language="vb" for="pbi" >
function AddRoom(){
Call pbi.rooms.Add("Room1")
<button on click =AddRoom()>..............

Regards referencing the object from code behind.
Well, any asp.NET object you put in a web  page needs to have a ref to it in the code behind.
If you plonk a panel on aspx  page from the toolbox, then a line like
protected System.Web.UI.WebControls.Panel Panel1; will appear in the code behind and you code to it using Panel1.Property

Well, is your ActiveX a client side control  or a server side  control ??? If you embedd it in a web page then it would appear to be a client side control.
But it could, if registered on the server, also be a serverside control.
If it was registered on the server then you would need to create a reference  to it to use it with code behind ... and you couldn't simply use something like System.Web.UI.WebControls.Panel Panel1; because it is not part of the .NET libraries. You would need to look at Interop and how to import a COM component  ... off the top of my head I don't know - but I do know that it can be done and is not very hard to do.
Once this is done then accessing the ActiveX server object's methods should be ok.

Note :: There are 2 different scenarios mentioned above.
A client side ActiveX control will simply be downloaded to the client and all of its functionality is wrapped into it. If it needs to access the server then it must do it itself.It must be registered on the client machine (their downfall!).
A server side ActiveX is one that is registered on the server, it can be imported into a .NET assemby and its methods accessed, those methods may access resources on the server (db, etc) and may output html as whole or part of the aspx page.
In this sense they appear to be similar to a .NET server control, indeed they are. BUT .... an ActiveX server control of this nature would not be added  to the aspx designer  code as you have shown below .... it would appear purely in the code. The reason is that the object tags you see that are added to the designer when you plonk a server control on an aspx page are whooly part of .NET .... do NOT think of them as actual code but think o fthem as HTML that is outputted by code ... what appears there when it arrives on the client is NOT an embedded control it is plain and simple html.
Ther is another type of embedded control .... similar to a java applet ... a windows control that is embedded in a web page. It has a tag like
<object id="wincontrol" classid="exeone.exe#exeone.mycontrol1" width=448 height=305> and runs CLIENT SIDE after being downloaded.
and again, this is NOT a server web control, just as the below is NOT a server web control, and a java applet is NOT a server web control.

<OBJECT id="pbi" style="Z-INDEX: 101; LEFT:
95px; WIDTH: 521px; POSITION: absolute; TOP: 59px; HEIGHT: 175px"
classid="clsid:CB93D4CA-F746-11D2-9118-00A0241E587F" name="pbi">
immediately implies that the ActiveX object is running client side.

Didn't find what you were looking for? Find more on issues with using activex component on web form Or get search suggestion and latest updates.