.NET control event with java script handler

  • Thread starter Thread starter Mircea Pleteriu
  • Start date Start date
M

Mircea Pleteriu

Hi all,

I have created a .NET Windows control with c#.
I have placed the control on a HTML page within the OBJECT element.
Everything works fine up to now.

Now, I wanna implement the following stuff that the control must support.

The control must provide a method called InvokeJavaScriptFunction
The prototype of this method is:

InvokeJavaScriptFunction(<point to java script function>)

where <point to java script function> is a pointer to an existing java
script function in the HTML page.

The InvokeJavaScriptFunction method of the control is invoked within the
HTML page when the page is loading

<head>
<script language="javascript">
function MyJScriptFunction()
{
....
}
</script>
<OBJECT id="MyControl" .....>
</OBJECT>
</head>
<body onLoad="MyControl.InvokeJavaScriptFunction(MyJScriptFunction)">
......
</body>

Inside the control.... the InvokeJavaScriptFunction is performing some stuff
and after that it should invoke the java script function on the page.
In other words, the InvokeJavaScriptFunction takes some actions and then it
must turn back the control on the page invoking the script function.
You can think at this like to an event.. the InvokeJavaScriptFunction is
doing its job and then fires an event on the page, where the handler of the
event is the provided java script function.

Do you have any idea how to implement this must have functionality of my
control?

Thanks,
Mircea
 
I have only done this in unmanaged world (and even there it's not trivial):

The function gets passed as VT_IDISPATCH parameter to your objects method.
You need to invoke the default method on that dispatch interface. As I said,
I haven't done this in managed code so you need to translate this into
managed code yourself.

Jerry
 
Back
Top