Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > ImageButton bug

Reply
Thread Tools

ImageButton bug

 
 
beanweed
Guest
Posts: n/a
 
      06-02-2005
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?
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      06-02-2005
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


 
Reply With Quote
 
 
 
 
beanweed
Guest
Posts: n/a
 
      06-02-2005
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?

"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
>
>
>

 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      06-04-2005
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
*bug* *bug* *bug* David Raleigh Arnold Firefox 12 04-02-2007 03:13 AM
Imagebutton / Image bug? Peter ASP .Net 3 06-19-2006 01:45 PM
weird bug with ImageButton.. i think?? Brian ASP .Net 4 04-25-2005 08:53 PM
image/imagebutton client validation ganesh kolappan ASP .Net 2 07-03-2003 06:56 PM
Prevent Postback with ImageButton Marcelo ASP .Net 3 07-01-2003 07:13 PM



Advertisments