How to call OCX functions from .js in C# .net code behind

Hi experts,
I'm not really sure if my question is going to be right, but here it goes.
I have a vb6 OCX that works with maps.
It has some functions that returns values like geocoding, reverse geocoding, driving directions, etc
For example, there is a function to add a point to the built map:

map.AgregarPunto(double latitude, double longitude, int point_id)

It works in a Win Form app, but I cannot make it work in a web page, because I think that the OCX is not designed for web.
I managed to call some functions in javascript -previously added the map with <OBJECT>- but I need to make it work from C# code behind.
Is there a way to do that?

Any help will be really appreciated.
Thanks in advance.
Regards,

Leandro Nuñez.
LVL 2
LeandronnAsked:
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.

MogalManicCommented:
Have you added the ocx and instanciated it?

Are you getting any exceptions?
0
LeandronnAuthor Commented:
Dear MogalManic:

It's instanced as INTEROP.ocxname.DLL
There are no exceptions, I'm able to retrieve the map, but I need to figure out a way to call the .js functions from my code behind... Something like the example I'll attach as code.

Thanks in advance for your answer.
/////////////////THIS IS WHAT I COULD DO/////////////////////////
//javascript

function AgregarPunto(){
    var mapa = document.GetElementByID("axMapa");
    mapa.AgregarPunto(-34.554433,-58.554322);
    mapa.Actualizar();
}

//aspx
<input id="btn2" type="button" value="punto" onclick="AgregarPunto()" />


/////////////////THIS IS WHAT I NEED TO DO/////////////////////////


//cybMap.ascx user control 

<object id="axMapa"/>

//aspx

<%@ Register Src="~/cybMap.ascx" TagName="cybMap" TagPrefix="cybMap" %>
<cybMap:cybMap id="mapa" runat="server />
<asp:button id="btnAgregarPunto" runat="server" onClick="btnAgregarPunto" />

//code behind

public void btnAgregarPunto(object sender, EventArgs e)
{
    double latitud = -34.4443333;
    double longitud = -58.45533332;
    this.mapa.AgregarPunto(latitud, longitud);
    this.mapa.Actualizar();
}

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

LeandronnAuthor Commented:
PeteEngineer:
My basic problem, is that I'm not a genius in javascript programming, and I don't have the time to make my OCX working with javascript (which I know it works great)

I've found a solution that uses google maps api, to build maps using a webservice, and everything is called from the code behind (http://www.c-sharpcorner.com/UploadFile/shabdarghata/google-maps-user-control-for-ASP-Net-part103232008234414PM/google-maps-user-control-for-ASP-Net-part1.aspx) but every function is written in javascript.

Hope you understand my question.


Regards,

Leandro Nuñez.
0
MogalManicCommented:
You cannot call the JavaScript from the codebehind.  The Javascript resides in the browser and the CodeBehind is on the server.  So if you are registering the OCX on the server, it won't exist on the client (and vice versa)
0
LeandronnAuthor Commented:
MogalManic:
I think that the differences between server and client should be discarded... I already know them...
So? How should OCX functions from the server?

Thanks anyways for your answer.
0
MogalManicCommented:
They should function from the server.  There are two forms of OCX.  Most of them render them-selfs to a form and require GDI functionality.

How are you registering the DLL.  You should be able to just create a new instance of the object.  So if the registered object is INTEROP.ocxname you should be able to create a new instance like this:
  INTEROP.ocxname OcxObject=new INTEROP.ocxname();
   object result=OcxObject.ObjectMethod(param1);

If the function returns a result you can then send it pack to the page.




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
LeandronnAuthor Commented:
Dear MogalManic:
It was a great answer!, I finally could call my functions from the code behind.
There is just one issue to resolve in this case now:

How do I relate my <OBJECT ID="axMapa"> to the NEW OBJECT in my codebehind?

Hope you understand my question.

Thanks in advance.

Regards,

LEandro Nuñez.
0
LeandronnAuthor Commented:
There are some things missing to complete my question
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.