ImageButton bug

Discussion in 'ASP .Net Web Controls' started by beanweed, Jun 2, 2005.

  1. beanweed

    beanweed Guest

    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?
     
    beanweed, Jun 2, 2005
    #1
    1. Advertising

  2. beanweed

    Teemu Keiski Guest

    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
     
    Teemu Keiski, Jun 2, 2005
    #2
    1. Advertising

  3. beanweed

    beanweed Guest

    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
    >
    >
    >
     
    beanweed, Jun 2, 2005
    #3
  4. beanweed

    Teemu Keiski Guest

    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
     
    Teemu Keiski, Jun 4, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcelo

    Prevent Postback with ImageButton

    Marcelo, Jul 1, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    946
    Kairi Zikpin
    Jul 1, 2003
  2. ganesh kolappan

    image/imagebutton client validation

    ganesh kolappan, Jul 3, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    502
    David Waz...
    Jul 3, 2003
  3. Matthew
    Replies:
    2
    Views:
    605
    Ken Cox [Microsoft MVP]
    Jul 9, 2003
  4. Brian
    Replies:
    4
    Views:
    300
    Brian
    Apr 25, 2005
  5. Peter

    Imagebutton / Image bug?

    Peter, Jun 19, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    2,288
    Bruno Alexandre
    Jun 19, 2006
Loading...

Share This Page