<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> Button_Click

     Click on the Image:     


  

      
'Default.asp part a) Partial Class _Default Inherits System.Web.UI.Page Protected Sub ImageButton_Click(sender As Object, e As ImageClickEventArgs) Handles ImageButton.Click Result.InnerText = "You clicked at (" & e.X.ToString() & ", " & e.Y.ToString() & "). " If e.Y < 130 And e.Y > 17 And e.X > 20 And e.X < 350 Then Result.InnerText &= "You clicked on the button surface." Else Result.InnerText &= "You clicked the button border." End If End Sub End Class <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> Circle

     Click Anywhere on the Circle:     


                     

' Default.aspx.vb part b) Partial Class _Default Inherits System.Web.UI.Page Protected Sub ImageButton_Click(sender As Object, e As ImageClickEventArgs) Handles ImageButton.Click Dim x As Integer, y As Integer Dim height As Integer, width As Integer height = 250 width = 250 x = e.X - (width / 2) y = (height / 2) - e.Y Dim theta As Double theta = (Math.Atan(y / x)) theta = (theta * 180) / Math.PI theta = Math.Abs(theta) If x < 0 And y > 0 Then theta = 180 - theta ElseIf x < 0 And y < 0 Then theta = 180 + theta ElseIf x > 0 And y < 0 Then theta = 360 - theta End If Dim radius As Double radius = Math.Sqrt((x * x) + (y * y)) If radius <= 125 Then If theta < 90 Then Result.Style("color") = "blue" Result.InnerHtml = "       You clicked inside blue portion." ElseIf theta > 90 And theta < 180 Then Result.Style("color") = "red" Result.InnerHtml = "       You clicked inside red portion." ElseIf theta > 180 And theta < 270 Then Result.Style("color") = "green" Result.InnerHtml = "       You clicked inside green portion." ElseIf theta > 270 And theta < 360 Then Result.Style("color") = "yellow" Result.InnerHtml = "       You clicked inside yellow portion." End If Else Result.Style("color") = "black" Result.InnerHtml = "       You clicked outside the circle." End If End Sub End Class