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" />
-
I think the best solution would be to call an ASP.NET Web Service using jQuery.ajax(). This article should help you: encosia.com/…Curtis– Curtis2011年07月08日 10:31:17 +00:00Commented Jul 8, 2011 at 10:31
2 Answers 2
Use __doPostBack function:
$("#ABC").click(function() {
__doPostBack('Save');
return false;
});
answered Jul 8, 2011 at 10:02
Comments
<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
Curtis
OnClientClick will try and run a javascript 'Save_Click' function, not the server-side click event..
lang-js