Button up/down event to server

  • Thread starter Thread starter eric.carmody
  • Start date Start date
E

eric.carmody

Hi all,

Trying to do the ol' button up/down changing view using a image - not a
input.

I have a couple variations that work nicely, but I have issues trapping
it from the server side.
I use the onmouse events to change the image; works good because no
roundtrip to the server when changing images. I can get them to
postback to the server, but the sender object in the page_load isn't
specific to the object, and I can not figure out what object caused the
submit.

Two different examples I've worked out are below. The <asp:image> tag
actually is in warning in the VS environment since that object doesn't
have a "name" attribute, but when its generated as HTML it does, so it
ends up working.

Both of these will cause the server side page_load to fire, but during
debug, the "sender" is the aspx page and not a control. How do I
determine who fired the submit? I thought the second example below
would do the trick, but it doesn't and I don't know why.

Thanks for you time and having a look. Appreciate comments and
suggestions.
Cheers,
Eric

<TD><IMG onmouseup="document.button1.src='images/button1_up.gif'"
onmousedown="document.button1.src='images/button1_down.gif'"
onmouseout="document.button1.src='images/button1_up.gif'"
onclick="Form1.submit();return true;"
src="images/button1_up.gif" name="button1">
</TD>

<TD><span onmouseup="document.button11.src='images/button11_up.gif'"
onmousedown="document.button11.src='images/button11_down.gif'"
onmouseout="document.button11.src='images/button11_up.gif'"
onclick="__doPostBack('button11','')">
<asp:image id="button11" EnableViewState="true" runat="server"
ImageUrl="images/button11_up.gif" name="button11">
</asp:image>
</span>
</TD>
 
Hello, eric

One way will be setting some hidden variable to specific value. Your client side code knows the where it is executing, right? Then, on server you can check the value of that hidden field and determine what to do...

Maybe this is not the best approach, but it should work

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Back
Top