B
beanweed
The click event arguments 'x' and 'y' are wrong if the dpi setting is not
96dpi.
Here is the code for a ImageButton control sample:
<%@ Page Language="VB" %>
<html>
<head>
<script language="VB" runat="server">
Sub ImageButton_Click(sender As Object, e As ImageClickEventArgs)
Label1.Text = "Coordinates: " & e.X.ToString() & "," & e.Y.ToString() &
")"
End Sub
</script>
</head>
<body>
<form runat="server">
<asp:ImageButton id="imagebutton1" runat="server"
ImageAlign="left"
ImageUrl="anyimage.jpg"
Width="200"
Height="300"
OnClick="ImageButton_Click"/>
<br><br>
<asp:label id="Label1" runat="server"/>
</form>
</body>
</html>
Note that the width and height are set. I have also used CSStyle (by itself
and with Width/Height) to constrain the size.
At the normal font setting of 96dpi the image is the correct size and the
maximum "Coordinates:" is 199,299. But if the font setting is large (125% or
120dpi, like a laptop) then the image is 200 by 300 pixels, even if it looks
smaller on the screen, but I can click on "Coordinates:249,374". I don't see
how it is possible for me to have an x and y that are beyond the size of the
image! In the alternative, how could one get the dpi setting of the client
machine and scale the e.x, e.y values?
96dpi.
Here is the code for a ImageButton control sample:
<%@ Page Language="VB" %>
<html>
<head>
<script language="VB" runat="server">
Sub ImageButton_Click(sender As Object, e As ImageClickEventArgs)
Label1.Text = "Coordinates: " & e.X.ToString() & "," & e.Y.ToString() &
")"
End Sub
</script>
</head>
<body>
<form runat="server">
<asp:ImageButton id="imagebutton1" runat="server"
ImageAlign="left"
ImageUrl="anyimage.jpg"
Width="200"
Height="300"
OnClick="ImageButton_Click"/>
<br><br>
<asp:label id="Label1" runat="server"/>
</form>
</body>
</html>
Note that the width and height are set. I have also used CSStyle (by itself
and with Width/Height) to constrain the size.
At the normal font setting of 96dpi the image is the correct size and the
maximum "Coordinates:" is 199,299. But if the font setting is large (125% or
120dpi, like a laptop) then the image is 200 by 300 pixels, even if it looks
smaller on the screen, but I can click on "Coordinates:249,374". I don't see
how it is possible for me to have an x and y that are beyond the size of the
image! In the alternative, how could one get the dpi setting of the client
machine and scale the e.x, e.y values?