[RESOLVED]Execute JQuery After Postback

Hey, I’m trying to run a simple jquery script. I’ve got it working without a postback but I want to be able to click a linkbutton, have a postback and then have the jquery execute.

Here’s the script for context:

$(document).ready(function () {
    $("[id$=lnkRemove]").click(function () {
        $dataribbon = $(".ribbon-content");

I’ve read about ScriptManager and it has this that could be useful:


I’m not entirely sure how that works and other than that, there doesn’t seem to be a lot of resources for running javascript/jquery after a postback. I’ve also read a bit about UpdatePanels and partial postbacks. Can anyone tell me the best way to approach

Make your js code a normal function

function myFunction() {
    $("[id$=lnkRemove]").click(function () {
        $dataribbon = $(".ribbon-content");

In the click event handler for your linkbutton, use RegisterStartupScript to write js to call the "myFunction" function.  Google for RegisterStartupScript for examples.

Hi FireVulpes,

Thanks for your post.

As for your problem, you could refer to the following sample to call a javascript function from server side.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
        function myFunction() {
            alert("Hello World");
    <form id="form1" runat="server">
        <asp:LinkButton ID="btnok" runat="server" OnClick="btnok_Click">CallClientSideFunction</asp:LinkButton>
protected void btnok_Click(object sender, EventArgs e)
    //your code
    ScriptManager.RegisterStartupScript(this, GetType(), "myFunction", "myFunction();", true);

If you have any question about this issue, please post back freely.

Best Regards,

Fei Han

Leave a Reply