Get position from ImageClickEventArgs : Image Button « Asp Control « ASP.Net






Get position from ImageClickEventArgs


<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

    Sub btnTarget_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs)
        If (e.X > 90 And e.X < 110) And (e.Y > 90 And e.Y < 110) Then
            lblResult.Text = "You hit the target!"
        Else
            lblResult.Text = "You missed!"
        End If
    End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>ImageButton Target</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ImageButton
        id="btnTarget"
        ImageUrl="http://www.java2s.com/style/logo.png"
        Runat="server" 
        OnClick="btnTarget_Click"
        Width="200"
        Height="300" />
    
    <asp:Label
        id="lblResult"
        Runat="server" />
    </form>
</body>
</html>

 








Related examples in the same category

1.Determining the Coordinates Clicked on the Image of an ImageButton Control (VB.net)
2.Simple ImageButton control (VB.net)
3.asp:ImageButton AlternateText (VB.net)
4.For loop inside asp:ImageButton Click event (VB.net)
5.Set ImageUrl for asp:Image (VB.net)
6.Use Image Button event (VB.net)
7.Deal with button action event arguments: x, y coordinates (C#)
8.Get Image Button mouse cursor coordinates (C#)
9.Link Javascript function to OnClientClick event