David Stephen
November 14th, 2002, 06:50 PM
is it possible to catch events generated by .net windows controls on a web browser?
I created a simple test windows control in VB.net with a button on the control.
When the button is pressed an event is fired after the message box is shown.
Public Class UserControl1
Inherits System.Windows.Forms.UserControl
Public Event Clicked As EventHandler
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MessageBox.Show("Clicked")
RaiseEvent Clicked(Me, e)
End Sub
End Class
I put script to catch the event and also on the body load the event is attached.
<script language=jscript for=UserControl1 event=Clicked()>alert("Clicked")</script>
<script language=jscript>
function Load()
{
UserControl1.attachEvent("Clicked", f1);
}
function f1()
{
alert("Clicked");
}
</script>
<object id="UserControl1" name="UserControl1" classid="http:WindowsControlLibrary1.dll#WindowsControlLibrary1.UserControl1" width="200" height="200" VIEWASTEXT>
</object>
Both fail to catch the event when the button is clicked. The message box shows, but the jscript does not catch the event.
Do I define the event this way?
I tried it with out the As EventHandler and got the same result of nothing happenning.
Does anyone know how I should define the event or how I should catch the event on the page?
Thank you
David Stephen
I created a simple test windows control in VB.net with a button on the control.
When the button is pressed an event is fired after the message box is shown.
Public Class UserControl1
Inherits System.Windows.Forms.UserControl
Public Event Clicked As EventHandler
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MessageBox.Show("Clicked")
RaiseEvent Clicked(Me, e)
End Sub
End Class
I put script to catch the event and also on the body load the event is attached.
<script language=jscript for=UserControl1 event=Clicked()>alert("Clicked")</script>
<script language=jscript>
function Load()
{
UserControl1.attachEvent("Clicked", f1);
}
function f1()
{
alert("Clicked");
}
</script>
<object id="UserControl1" name="UserControl1" classid="http:WindowsControlLibrary1.dll#WindowsControlLibrary1.UserControl1" width="200" height="200" VIEWASTEXT>
</object>
Both fail to catch the event when the button is clicked. The message box shows, but the jscript does not catch the event.
Do I define the event this way?
I tried it with out the As EventHandler and got the same result of nothing happenning.
Does anyone know how I should define the event or how I should catch the event on the page?
Thank you
David Stephen