Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 997469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:02:21+00:00 2026-05-16T07:02:21+00:00

Greetings all, I have a simple JQuery function which is bound to an ASP:Button

  • 0

Greetings all,

I have a simple JQuery function which is bound to an ASP:Button and fires when the submit button is clicked, like this:

<asp:Button ID="btnSubmit" CssClass="btnSubmit" OnClick="btnSubmit_Click" runat="server"
                Text="Send" />

$(document).ready(function () {
    $(".btnSubmit").click(function () {
        alert("button clicked");
    });
});

This code runs correctly the first time the page is loaded, but never runs again after clicking Submit (and a post/postback occurs). The asp button code is within an UpdatePanel. It seems like the JQuery code is being “unregistered” or unbound after the postback. I have a ScriptManager control on the page but this is all I’m doing with it:

<asp:ScriptManager ID="ContactFormScriptManager" runat="server">
  <Scripts>
    <asp:ScriptReference Path="Scripts/jquery-1.4.1.js" ScriptMode="Auto" />
    <asp:ScriptReference Path="Scripts/contact-form.js" ScriptMode="Auto" />
  </Scripts>
</asp:ScriptManager>

I suspect there’s more I need to do with ScriptManager to make sure my JQuery code stays registered, but I’m not sure what. Your suggestions would be appreciated.

Thanks,
-NorthK

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:02:22+00:00Added an answer on May 16, 2026 at 7:02 am

    @Sarfraz is right about the solution but I thought you may want some explanation as to why this works:

    $(function () {
      $(".btnSubmit").live("click", function() {
        alert("button clicked");
      });
    });
    

    It’s not that it’s being “unregistered”, it’s that the elements in the UpdatePanel are completely destroyed/replaced by new elements. Since the click handler is stored on those elements (well, not exactly, but close) it’s not automatically created for the new elements.

    .live() however works differently, it adds an event handler to document which isn’t getting replaced. It listens for the click event to bubble up the DOM and reach document. When it gets there it checks if the element the event came from matches the selector…if the selector matches, it executes the handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings all, I have some JSON code that looks like this: { playlist: [
Greetings All; I have a LinkedList of type String which contain some words like
Greetings all... I have a simple, yet annoying question regarding Spring Web MVC. I
Greetings everyone I have this regular expression which goes as follow: $thread_views_exp = '~<td
Greetings All; I have a desktop java application which gives the following output in
Greetings all, I have posted this on the MSDN managed news groups as well
Greetings to all! This is my first question here on stackoverflow. I have a
greetings all i have an application which are made with Spring framework and deployed
greetings all I have a post method in a controller, which redirects to a
Greetings all, As seen in the picture I have an extended QWidget object (which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.