Trapping click events in the Image control

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Trapping click events in the Image control

    Can anyone tell me how to trap mouse click events in the
    Image control?

    I am trying to implement an image zoom feature using
    JavaScript where the user could "draw" a zoom box (aka
    rubber band box) on the image and the image would zoom to
    the extents of the box.

    Anyone know how to accomplish this?

    Thanks!

    Jeff Ptak
    Jeff Ptak Guest

  2. Similar Questions and Discussions

    1. Click event on Image Control
      Hello , There is an Image control created on the page, the logic: when user clicks on the Image, it needs to perform some action(such as calling...
    2. Capturing Click Events in Buttons
      i have three buttons in my custom web control and im not able to capture click events on em. how to do this in custom control. buttons are...
    3. Notify child control of events in parent control
      I have a parent control that has a imagebutton on it, with code to handle the click event. I also have various ascx controls that are loaded by the...
    4. Trapping mouse events
      Is there a way to have a movie clip trap all mouse events and not pass them on to any other MCs/buttons that are underneath it? In other words,...
    5. Datagrid click events
      Can someone please help me figure out why this code does not run. I have tried it on a Datagrid selectedindexchanged event as well. I can fill...
  3. #2

    Default Re: Trapping click events in the Image control

    Hi Jeff,

    That sounds like an interesting challenge.

    If you can use IE only, there are drag events that you can grab and use. Here's
    a quickie demo:

    <form id="Form1" method="post" runat="server">
    <asp:image id="Image1" runat="server"
    imageurl="http://canada.gc.ca/images/rollingflag.jpg"></asp:image>
    <script for="Image1" event=ondragend>
    alert(window.event.offsetX );
    </script>
    </form>

    There's lots more here:

    [url]http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtml_reference_entry.asp[/url]

    Ken


    "Jeff Ptak" <ptakja@NOSPAM.corning.com> wrote in message
    news:928c01c35b90$7ca8a070$a001280a@phx.gbl...
    Can anyone tell me how to trap mouse click events in the
    Image control?

    I am trying to implement an image zoom feature using
    JavaScript where the user could "draw" a zoom box (aka
    rubber band box) on the image and the image would zoom to
    the extents of the box.

    Anyone know how to accomplish this?

    Thanks!

    Jeff Ptak


    Ken Cox [Microsoft MVP] Guest

  4. #3

    Default Re: Trapping click events in the Image control

    Natty,

    Can you share the VML code to draw rubber band box
    How did you draw the rubber band box
    Getting the coordinates is easy then dealing with it on the server is easy
    but I am not familiar with the VML Rubber Band Box

    Thank you for sharing

    J
    "Natty Gur" <natty@dao2com.com> wrote in message
    news:eGe%23H89WDHA.2204@TK2MSFTNGP12.phx.gbl...
    > Jeff Hi,
    >
    > we did it with GIS application, basicly we
    > use the mouse event to trap the mouse down and then mouse move. while
    > the mouse move we use VML to drow rubber band box. when the mouse up we
    > send the cordination of the VML object to the server to create new image
    > on the server and return it to the client.
    >
    >
    > Natty Gur, CTO
    > Dao2Com Ltd.
    > 34th Elkalay st. Raanana
    > Israel , 43000
    > Phone Numbers:
    > Office: +972-(0)9-7740261
    > Fax: +972-(0)9-7740261
    > Mobile: +972-(0)58-888377
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    MS News \(MS LVP\) Guest

  5. #4

    Default Re: Trapping click events in the Image control

    Hi,

    You welcome, here is the code that draw the rectangle. Its part of long
    js file. the complicate part is keeping the start and current mouse
    coordinates and interact with ArcIMS .

    function DrawRectangle(){

    if (event.button==rightButton && pointCount==0){
    return false;
    }

    if (event.button==leftButton && pointCount==0){
    //Left click mouse - create a new point in the polyline

    if (lastXX != get_x() || lastYY != get_y() ){ //This "IF"
    check if you do DOUBLCLICK" alert ('Same Point') };

    add_point(get_x(),get_y());

    lastXX = get_x();
    lastYY = get_y();

    }

    }

    if
    (arcims_poly!=null){document.all.arcims_draw.remov eChild(arcims_poly);}
    arcims_poly=document.createElement("<v:Polyline filled=\"False\"
    strokecolor=\"red\" strokeweight=\"2pt\" points=\"" +
    arrPoint.toString() +"\"></v:polyline>");
    document.all.arcims_draw.appendChild(arcims_poly);

    if (event.button==leftButton && pointCount==1){
    return false;
    }




    if (event.button==rightButton && pointCount == 1){
    lastXX = get_x();
    lastYY = get_y();
    showDynamicRectangle(lastXX, lastYY);
    // alert(arrCoord.toString() + " <>" + arrPoint.toString());
    pointCount = 0;
    return false;
    }

    pointCount++; //After the first point

    arrPoint[1]=new Array(2);
    arrPoint[2]=new Array(2);
    arrPoint[3]=new Array(2);
    arrPoint[4]=new Array(2);
    arrCoord[1]=new Array(2);
    arrCoord[2]=new Array(2);
    arrCoord[3]=new Array(2);
    arrCoord[4]=new Array(2);

    }



    Natty Gur, CTO
    Dao2Com Ltd.
    34th Elkalay st. Raanana
    Israel , 43000
    Phone Numbers:
    Office: +972-(0)9-7740261
    Fax: +972-(0)9-7740261
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  6. #5

    Default Re: Trapping click events in the Image control

    Thank you


    "Natty Gur" <natty@dao2com.com> wrote in message
    news:%23qcdp5%23WDHA.2352@TK2MSFTNGP12.phx.gbl...
    > Hi,
    >
    > You welcome, here is the code that draw the rectangle. Its part of long
    > js file. the complicate part is keeping the start and current mouse
    > coordinates and interact with ArcIMS .
    >
    > function DrawRectangle(){
    >
    > if (event.button==rightButton && pointCount==0){
    > return false;
    > }
    >
    > if (event.button==leftButton && pointCount==0){
    > //Left click mouse - create a new point in the polyline
    >
    > if (lastXX != get_x() || lastYY != get_y() ){ //This "IF"
    > check if you do DOUBLCLICK" alert ('Same Point') };
    >
    > add_point(get_x(),get_y());
    >
    > lastXX = get_x();
    > lastYY = get_y();
    >
    > }
    >
    > }
    >
    > if
    > (arcims_poly!=null){document.all.arcims_draw.remov eChild(arcims_poly);}
    > arcims_poly=document.createElement("<v:Polyline filled=\"False\"
    > strokecolor=\"red\" strokeweight=\"2pt\" points=\"" +
    > arrPoint.toString() +"\"></v:polyline>");
    > document.all.arcims_draw.appendChild(arcims_poly);
    >
    > if (event.button==leftButton && pointCount==1){
    > return false;
    > }
    >
    >
    >
    >
    > if (event.button==rightButton && pointCount == 1){
    > lastXX = get_x();
    > lastYY = get_y();
    > showDynamicRectangle(lastXX, lastYY);
    > // alert(arrCoord.toString() + " <>" + arrPoint.toString());
    > pointCount = 0;
    > return false;
    > }
    >
    > pointCount++; //After the first point
    >
    > arrPoint[1]=new Array(2);
    > arrPoint[2]=new Array(2);
    > arrPoint[3]=new Array(2);
    > arrPoint[4]=new Array(2);
    > arrCoord[1]=new Array(2);
    > arrCoord[2]=new Array(2);
    > arrCoord[3]=new Array(2);
    > arrCoord[4]=new Array(2);
    >
    > }
    >
    >
    >
    > Natty Gur, CTO
    > Dao2Com Ltd.
    > 34th Elkalay st. Raanana
    > Israel , 43000
    > Phone Numbers:
    > Office: +972-(0)9-7740261
    > Fax: +972-(0)9-7740261
    > Mobile: +972-(0)58-888377
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    MS News \(MS LVP\) Guest

  7. #6

    Default Re: Trapping click events in the Image control

    Not sure why the code didn't make it in the other message. Maybe there's a
    filter to catch the tags?


    Hi Jeff,

    That sounds like an interesting challenge.

    If you can use IE only, there are drag events that you can grab and use. Here's
    a quickie demo:

    <form id="Form1" method="post" runat="server">
    <asp:image id="Image1" runat="server"
    imageurl="http://canada.gc.ca/images/rollingflag.jpg"></asp:image>
    <script for="Image1" event=ondragend>
    alert(window.event.offsetX );
    </script>
    </form>

    There's lots more here:

    [url]http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtml_reference_entry.asp[/url]

    Ken

    "Jeff Ptak" <ptakja@NOSPAM.corning.com> wrote in message
    news:928c01c35b90$7ca8a070$a001280a@phx.gbl...
    Can anyone tell me how to trap mouse click events in the
    Image control?

    I am trying to implement an image zoom feature using
    JavaScript where the user could "draw" a zoom box (aka
    rubber band box) on the image and the image would zoom to
    the extents of the box.

    Anyone know how to accomplish this?

    Thanks!

    Jeff Ptak


    Ken Cox [Microsoft MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139