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" />
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;
});
Sign up to request clarification or add additional context in comments.

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?

1 Comment

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

Your Answer

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.