Solved

Webform: Click picture instead of a button to submit?

Posted on 2004-09-27
9
263 Views
Last Modified: 2010-04-15
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
0
Comment
Question by:ianinspain
  • 4
  • 4
9 Comments
 

Author Comment

by:ianinspain
ID: 12161894
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
 
LVL 15

Expert Comment

by:praneetha
ID: 12162114
no use image button instead

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

and u can double click to see teh click event
0
 
LVL 3

Expert Comment

by:stu_pb
ID: 12162214
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:ianinspain
ID: 12162226
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
 
LVL 15

Accepted Solution

by:
praneetha earned 500 total points
ID: 12162266
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
 

Author Comment

by:ianinspain
ID: 12162766
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
 
LVL 15

Expert Comment

by:praneetha
ID: 12162805
i think image control is nothing but html image with runat server...it doesn't have any events..

0
 

Author Comment

by:ianinspain
ID: 12162955
Thanks anyway.. awarding points now..

much appreciated

ian
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12163476
thanks for the points...good luck
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Code works but it's slow 28 76
Simple Injector with Web Service 4 54
Best resource to learn entity framework 2 47
RegEx with optional part 4 42
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question