2

I am working with Asp.Net. asp:button's OnClick event like the below. I would like to have jquery call "Save_Click' event. Is it possible?

Home.aspx.cs code

protected void Save_Click(object sender, EventArgs e)
 {
 //code to update database goes here....
 }

jquery code

$("#ABC").click(function() {
 $($get("Save")).click();
 return false;
 });

.aspx

<asp:Button id="Save" runat="server" Text="Save Details" OnClick="Save_Click" />
<input id="ABC" type="button" value="button" />
asked Jul 8, 2011 at 9:59
1
  • I think the best solution would be to call an ASP.NET Web Service using jQuery.ajax(). This article should help you: encosia.com/… Commented Jul 8, 2011 at 10:31

2 Answers 2

2

Use __doPostBack function:

$("#ABC").click(function() {
 __doPostBack('Save');
 return false;
});
answered Jul 8, 2011 at 10:02

Comments

0
<asp:Button id="Save" runat="server" Text="Save Details" OnClientClick="Save_Click" />

This is will work or u can do something like :

$(document).ready(function() {
$("input[id$='yourinputbutton']").click(function() {
// Do client side button click stuff here.
});
});

Are you looking for Jquery asp.net Button, What exactly you want to acheive?

answered Jul 8, 2011 at 10:04

1 Comment

OnClientClick will try and run a javascript 'Save_Click' function, not the server-side click event..

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.