An HTML image input element does the same thing that an HTML submit input
element does. It submits the form. When any form element or JavaScript that
submits a form submits the form, the form doesn't contain any information
regarding what element submitted the form. Now, there are a couple of ways
to pass this information back to the server, and both of them require
JavaScript. One (the easiest) is to use a Server Control for your HTML image
input element, and to write a server-side Event Handler for it. However, you
mysteriously stated that you "don't want to also have to dynamically specify
a delegate for an event procedure to handle this control..." I find it
mysterious because you didn't state any logical justification for not
wanting to do that. It almost appears as if you have something against the
ASP.Net object-oriented programming model. The second way is to roll your
own event handler, by adding an "onclick" client-side JavaScript event
handler that puts the ID or name of the control into a hidden form field and
submits the form. On the server side, the class can then read the contents
of the hidden form field to find out what element submitted the form.
Interestingly enough, this is exactly what ASP.Net does when you use a
Server Control with an Event Handler delegate.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
"Jordan" <A@B.com> wrote in message
news:ue**************@TK2MSFTNGP10.phx.gbl...
I am dynamically inserting an html <input> tag as text (equivalent of an
image button) into a page via a Literal control.
Something like this gets inserted:
<input type="image" name="MyImageButton" id="MyImageButton"
src="somePic.jpg" />
I want for the code-behind to "know" when the user clicked on the image -
but I don't want to also have to dynamically specify a delegate for an
event procedure to handle this control which is really inserted as a
simple string at runtime under limited conditions.
I was thinking/hoping that I could simply determine (somehow) in the
Page_Load event if the current PostBack was caused by a user clicking on
the image - and then take required action. So, how can I determine in
Page_Load that the current PostBack was caused by the user clicking on the
image/<input>?
Thanks!