I've created a windows form control which works successfully hosted in Internet Explorer. I'd like to give it an event and be able to respond to the event through javascript. I found a link that talks about it here. It shows me how to create the interfaces but I'm not sure how to fire the event from my control?
Here's my code snippetS:
//Control Code:
public class CardReader : Panel,ICardReaderEvents, ICardReaderProperties
{
public void Error()
{
}
public void Success()
{
}
}
//Interface for events
[Guid("DD0C202B-12B4-4457-9FC6-05F88A6E8BC5")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ICardReaderEvents
{
[DispId(0x60020000)]
void Error();
[DispId(0x60020001)]
void Success();
}
//Interface for public properties/methods
public interface ICardReaderProperties
{
...
}
//JavaScript to handle events
<SCRIPT FOR="CardReader1" EVENT="Error">
window.status = "Error...";
</SCRIPT>
<SCRIPT FOR="CardReader1" EVENT="Success">
window.alert("Success");
window.status = "";
</SCRIPT>