Determining the Coordinates Clicked on the Image of an ImageButton Control (VB.net) : Image Button « Asp Control « ASP.Net






Determining the Coordinates Clicked on the Image of an ImageButton Control (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)

End Sub
Sub SubmitBtn_Click(Sender As Object, E As ImageClickEventArgs)
    Dim String1 as String
    Dim String2 as String
    If E.X < 18 then
        String1 = "Left"
    Else
        String1 = "Right"
    End If
    If E.Y < 18 then
        String2 = "Top"
    Else
        String2 = "Bottom"
    End If
    lblLocationClicked.Text = "You clicked in the " & String2 _
        & "-" & String1 & " portion of the image."
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Determining the Coordinates Clicked on the Image of an ImageButton Control</TITLE>
</HEAD>
<form runat="server">
<asp:label 
    id="lblLocationClicked" 
    runat="server"
/>
<BR><BR>
<asp:imagebutton 
    id="imagebutOK"
    alternatetext="View Coordinates"
    imageurl="http://www.java2s.com/style/logo.png"
    onclick="SubmitBtn_Click" 
    runat="server"
/>
</form>
</BODY>
</HTML>
           
       








Related examples in the same category

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