Solved

Webform: Click picture instead of a button to submit?

Posted on 2004-09-27
9
258 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:ianinspain
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 15

Accepted Solution

by:
praneetha earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
i think image control is nothing but html image with runat server...it doesn't have any events..

0
 

Author Comment

by:ianinspain
Comment Utility
Thanks anyway.. awarding points now..

much appreciated

ian
0
 
LVL 15

Expert Comment

by:praneetha
Comment Utility
thanks for the points...good luck
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now