Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Forms with more than 1 submit button

I am trying to understand forms a little better in the context of building a .NET application (even though I now think that my question is actually more general than .NET).

In any case, I have an asp:button and and asp:imagebutton on my webform.  I have created onclick event handlers for each that just have a return statement in them.  I have put a breakpoint at each return statement so that I can look at the Request object in VS.NET

When I click on the asp:button, the appropriate event handler gets called, and the Request.Form has a key for Button1 (the name of the button).

When I click on the imagebutton, the Request.Form has a key for ImageButton1.x and ImageButton1.y.

There was no javascript in the sheet associated with these 2 controls (unlike for linkbuttons).

So, in short, can any one explain to me or point me in the right direction to understand how that information gets created in the Request.Form collection of keys?


Charles Reich
Friday, May 02, 2003

You obeserving how web browsers have been communicating with web servers for years. All HTML controls send a "name=value" pair to the server (or in the case of the image, additionally the x/y co-ordianate of where the click occurred). ASP.NET just wraps the event handling candy floss around all this to make it more like windows programming.

Duncan Smart
Friday, May 02, 2003

This sort of thing has being going on for a long time before javascript (or ASP.NET for that matter) came along... ASP.NET is a (leaky) abstraction on top of two simple, plaintext HTTP commands, GET and POST. A packet sniffer ot trace utility can be quite instructive to see what's going on. Something like will let you see what's going one between the browser and server (and how wonderfully straightforward and simple it is).

Duncan Smart
Friday, May 02, 2003

thanks duncan.  i'll definitely look into tcptrace.  Sounds like a great tool for learning and debuging

Charles Reich
Monday, May 05, 2003

I think it would be useful for you to read this article:

Good luck!

Mikhail Andronov
Tuesday, May 06, 2003

Thanks for the link Mikhail.

Charles Reich
Thursday, May 08, 2003

*  Recent Topics

*  Fog Creek Home