| 代码说明:传递有意义的EventArgs参数的一个控件例子时ImageButton控件。单击ImageButton时,EventArgs参数包含了所单击按钮的精确象素坐标信息。。
<Script Runat="Server">
Sub ImageButton_Click( s As Object, e As ImageClickEventArgs )
lblXLocation.Text = e.X
lblYLocation.Text = e.Y
If e.X = 100 and e.Y = 100 Then
lblMessage.Text = "!!! You Win !!!"
Else
lblMessage.Text = "You Missed!"
End If
End Sub
</Script>
<html>
<head><title>Dartboard.aspx</title></head>
<body>
Hit the dartboard:
<form Runat="Server">
<asp:ImageButton
Src="target.gif"
OnClick="ImageButton_Click"
Runat="Server" />
<p>
X Coordinate:
<asp:Label
id="lblXLocation"
Runat="Server" />
<p>
Y Coordinate:
<asp:Label
id="lblYLocation"
Runat="Server" />
<p>
<asp:Label id="lblMessage" Runat="Server" />
</form>
</body>
</html>
|