Get Image Button mouse cursor coordinates (C#) : Image Button « Asp Control « ASP.Net






Get Image Button mouse cursor coordinates (C#)

<%@ Page Language="C#" %>
<script runat="server">
    protected void btnTarget_Click(object sender, ImageClickEventArgs e)
    {
        if ((e.X > 90 && e.X < 110) && (e.Y > 90 && e.Y < 110))
            lblResult.Text = "You hit the target!";
        else
            lblResult.Text = "You missed!";
    }
</script>
<html>
<head>
    <title>ImageButton Target</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    <asp:ImageButton
        id="btnTarget"
        ImageUrl="http://www.java2s.com/style/logo.png"
        Runat="server" OnClick="btnTarget_Click" />
    
    <br /><br />
    
    <asp:Label
        id="lblResult"
        Runat="server" />
    
    </div>
    </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 position from ImageClickEventArgs
9.Link Javascript function to OnClientClick event