Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button probs calling method!

Status
Not open for further replies.

KenniM

Programmer
Nov 27, 2002
25
0
0
DK
Okidoki! here goes...

I have a form with two input controls and a submit button! When I click my submit button I want the aspx to PostBack and use a codebehind class method called "UpdateTasklist()".

This is not a problem if I use the <asp:button...> but I have my own (way cooler) button wich is of this format <a...><img.../></a>.

How is it possible to use my method this way? Or am I just getting of on the wrong foot here! :D

thanx!
 
Any <asp: clickable control will post the form back to itselve. You can use <asp:imagebutton.
You can use the runat=&quot;server&quot; on the html element that you want to trigger the server side click event.




Greetings, Harm Meijer
 
Tanx buddy!

<asp:imagebutton> works for me! I also tried adding a runat=&quot;server&quot; to my original button. But i can't get it to post back! Not at the moment anyway! :D

The reason why I'm interested in using my old-style button is because I have a feeling that its cleaner than using the asp:Imagebutton.

Any opinions on this subject?

Cheers
Kenni
 
You are correct:
<img runat-&quot;server&quot;
does not have a server click event

You can use:
<INPUT type=image runat=&quot;server&quot; id=&quot;myImage&quot;


and in the code behind:
' in the class varialbles:
Protected WithEvents myImage As System.Web.UI.HtmlControls.HtmlInputImage

' the sub that handles the click event:
Private Sub myImage_click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Image1.ServerClick
' some image click code here.
End Sub




Greetings, Harm Meijer
 
Thank you Harm Meijer! It works now! :D

Cheers Kenni

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top