Webform: Click picture instead of a button to submit?

Hi there,

just created a webform and normally I would have a submit button that would automatically submit it to the server so I can pickup up my click event on asp.net..

Is it possible to click a picture i have instead of a button?

I have used a standard <img src=""> to insert my picture .... I suppose I should have used a Picture VS.NET Web control?? Is this correct?

I wonder if its possible to force a <img src=""> to submit a form and how I would go about this?

Any help or info would be gratefully appreciated

Ian
ianinspainAsked:
Who is Participating?
 
praneethaCommented:
yes it does

private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
            {
            

            }


private void InitializeComponent()
            {    
                  this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
                  this.Load += new System.EventHandler(this.Page_Load);

            }
0
 
ianinspainAuthor Commented:
Ermm strange... just tried adding a Image control to the webform ... and it displays ok... if I double click the image control I was suspecting I would goto codebehind view and get a Image1_click event.... but it doesn't give me one..

Am I missing something..??

0
 
praneethaCommented:
no use image button instead

<asp:ImageButton id="ImageButton1" runat="server"></asp:ImageButton>

and u can double click to see teh click event
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
stu_pbCommented:
You can use JavaScript to do this.

<img src="yourImage" onclick="document.all.yourFormName.submit()"></img>

This will submit the form when the image is clicked on.
0
 
ianinspainAuthor Commented:
Hi praneetha...

Yes I tried double clicking it ...which then shows me the codebehind... but I don't see the event being created...

Does it work your end??

0
 
ianinspainAuthor Commented:
ahh it was my fault i used a Image rather than an image button....

whooops!...

I would have thought that the image control would have some events too though..

thanks..
0
 
praneethaCommented:
i think image control is nothing but html image with runat server...it doesn't have any events..

0
 
ianinspainAuthor Commented:
Thanks anyway.. awarding points now..

much appreciated

ian
0
 
praneethaCommented:
thanks for the points...good luck
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.