ACTIVEX, WEB FORMS, AND INTEROP ISSUE

  • Thread starter Jeffery Franzen
  • Start date
J

Jeffery Franzen

Anyone know where the documentation is regarding Activex controls in asp web forms?

I'm using VS.NET 2002 enterprise and am trying to use Activex controls in vb.net web form app.

I do the add control to pallete and then add a reference. I get the interop dll added to bin folder.

I did this with the MediaPlayer activex control as a simple case to to try and get it working.

I set the control to autostart via the html parameter tag for the control.

Then I set it to stop in the page_load but it doesn't

What's the trick in getting apsx code to talk to the activex control?

I put the following code in the aspx file:

**************************************************************************************************************************************************
Imports MediaPlayer

Public Class host

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim obj As New MediaPlayer.MediaPlayerClass()

obj.Stop()

End Sub

End Class
 
S

Scott Allen

Hi Jeffery:

You'll want your interactions with media player to take place in the
client's browser, meaning you'll need client side script (JavaScript
etc).

Chances are you'll be doing everything client side and won't need a
reference or interop dll on the server. Dimming a new MediaPlayerClass
in Page_Load will create the player on the server, which I'm sure you
don't want. Know what I mean?
 
J

Jeffery Franzen

Hi Scott,

You are right. I used a bad example for what I was really trying to do with an activex control I built. I was trying to figure out if it is my control or just the way I use it in the vb.net asp code behind module. I am trying to load values into the control from the server side when the page is requested by the client. The reason I am using activex is that this control is part of a game lobby server and activex is the only way I know of to start the game on the client side. The control works fine in the web form except for the data exchange between the asp code and the control. I've read everything I could find on using COM objects in vb.net (or cs.net) web forms. Everything builds and runs fine. It's just that the web form code doesn't seem to be talking to the same instance of the activex control that is embedded in the asp page. I can set properties of the control and read them back via asp, but the control doesnt visually update any of them and if I change values in the displayed control they dont get reflected back to the asp code. If you or anyone else knows of an example of a working activex control in vb or cs.net code please let me know.

Thank you,
Jeff

Here are the steps I take to use the control:
1 - Build and register component(Borland CPP 6.0)
2 - Add the component to the Toolbox/Components in VS.NET
3 - Drag and drop the component from the toolbox to the asp design page
4 - Add a reference (COM) to the activex component library
5 - add the following code to the aspx code behind (bold print)

Imports ogl_x.ogl_il2launcherClass

Public Class host
Inherits System.Web.UI.Page
Protected WithEvents bCancel As System.Web.UI.WebControls.Button
Protected WithEvents lblTitle As System.Web.UI.WebControls.Label
Dim obj As ogl_x.ogl_il2launcherClass

#Region " Web Form Designer Generated Code "

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

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 Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim str As String
Dim obj As New ogl_x.ogl_il2launcherClass()
obj.ServerName = "My Server"

'Put user code to initialize the page here
'lblTitle.Text = str
Select Case Session("GameType")
Case "il2", "il2fb", "pfsa", "pfm"
Case Else
End Select
End Sub

Private Sub bCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bCancel.Click
Response.Redirect("lobby.aspx", False)
End Sub

End Class
 
S

Scott Allen

Hi Jeffrey:

The control works fine in the web form except for the data exchange between the asp code and the control. I've read everything I could find on using COM objects in vb.net (or cs.net) web forms. Everything builds and runs fine. It's just that the web form code doesn't seem to be talking to the same instance of the activex control that is embedded in the asp page.

Yes - because they are two seperate instances of the control. One you
instantiated in the clients browser, and a second one you are
instantiating on the server.

You'll need to set those properties on the client side with JavaScript
or VBScript for the appearance to change - anything that happens on
the server in Page_Load to an activeX control instantiated server side
won't be visible on the client's browser.
I can set properties of the control and read them back via asp, but the control doesnt visually update any of them and if I change values in the
displayed control they dont get reflected back to the asp code. If you or anyone else knows of an example of a working activex control in vb or cs.net code please let me know.

This article:

HOW TO: Host ActiveX Controls in a Web Form
http://support.microsoft.com/default.aspx?scid=kb;EN-US;317392

is a very simple example but notice how it changes the width of the
ActiveX chart control on the client - with a JavaScript function. If
you can find any examples for your control that use JavaScript you'll
be in business. The server side tech won't matter much at all - ASP,
ASP.NET, PHP, etc, because all the interaction will be in client side
script.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top