Home All Groups Group Topic Archive Search About
Author
2 Jun 2005 2:01 PM
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?

Author
2 Jun 2005 4:34 PM
Teemu Keiski
ImageButton in fact reads only what browser sends as arguments (I assume you
tried it with IE). Did you try with other browsers that what the results are
with them?

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
Author
2 Jun 2005 6:21 PM
beanweed
In Netscape, the coordinates are correct: if the dpi or screen size change,
the image size changes to accomodate and the maximum coordinates are always
the same. However,it ignores the size settings. It is crucial that the image
be the given size since the X and Y are used to look-up a value in an xml
document. I can and have made the image the correct size and this seems to
work, but I would rather be able to set the size using Width/Height or CSS.

I regret that I haven't tested in browsers other than Netscape and IE.

About 90% of my organization's users are using IE, so it will have to work
there at least. If I write a javascript to show the coordinates onmouseover,
it shows that the "event.x" and "event.y" at the bottom-right are 200,300,
regardless of the dpi or screen size. So why then does "e.X" and "e.Y" come
to be greater than that?

Show quoteHide quote
"Teemu Keiski" wrote:

> ImageButton in fact reads only what browser sends as arguments (I assume you
> tried it with IE). Did you try with other browsers that what the results are
> with them?
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
>
>
>
Author
4 Jun 2005 7:57 AM
Teemu Keiski
Just out of interest, did you try to restart IE after changing those
settings? (just interested if it has effect). I remember sometimes seeing
that those don't get updated correctly without browser restart. :-)

You could also try asking this in IE newsgroups.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU