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 1030369
In Process

The Archive Base Latest Questions

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

I have the javascript code below which disables an asp.net button during page postback.

  • 0

I have the javascript code below which disables an asp.net button during page postback. I also have a dropdownlist whose Autopostback property is set to true. Unfortunately, when i change the selectedItem in the dropdownlist, the button is disabled.

I want the Button disabled only when the page postback is caused by that same button, but not any other control on the page.

Some one please help on what change i should make to the code below to achieve this.

<script type="text/javascript">
    // Get a reference to the PageRequestManager.
    var prm = Sys.WebForms.PageRequestManager.getInstance();

    // Using that prm reference, hook _initializeRequest
    // and _endRequest, to run our code at the begin and end
    // of any async postbacks that occur.
    prm.add_initializeRequest(InitializeRequest);
    prm.add_endRequest(EndRequest);

    // Executed anytime an async postback occurs.
    function InitializeRequest(sender, args) {

        // Change the Container div's CSS class to .Progress.
        $get('Container').className = 'Progress';

        // Get a reference to the element that raised the postback,
        //   and disables it.
        $get(args._postBackElement.id).disabled = true;
    }

    // Executed when the async postback completes.
    function EndRequest(sender, args) {
        // Change the Container div's class back to .Normal.
        $get('Container').className = 'Normal';

        // Get a reference to the element that raised the postback
        //   which is completing, and enable it.
        $get(sender._postBackSettings.sourceElement.id).disabled = false;
    }                 
</script>
  • 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-16T12:41:22+00:00Added an answer on May 16, 2026 at 12:41 pm

    Well, you’re hooking into any asynchrous postback, sounds like you just want to hook into a particular button’s postback.

    However, you could fix this with minimal code adjustment, just by checking the ID of the control which triggered the postback before disabling it.

    if (args._postBackElement.id == idOfTheButton)
       $get(args._postBackElement.id).disabled = true;
    

    Of course, if your button is a server-side button (asp:button), then you would need to either render out the client-id to the client from the server, or access it directly:

    if (args._postBackElement.id == '<%= YourButton.ClientId %>')
       $get(args._postBackElement.id).disabled = true;
    

    As i said, there are better solutions than this (like only hooking into the postback event of the button, not any postback event).

    But nonetheless, this should solve your problem.

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

Sidebar

Ask A Question

Stats

  • Questions 511k
  • Answers 511k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try //event[@id="2"]/parent::events/@date Together with the original XPath: //event[@id="2"]/parent::events/@date | //event[@id="2"] May 16, 2026 at 5:25 pm
  • Editorial Team
    Editorial Team added an answer M1 means Milestone 1, it's a release name, like beta… May 16, 2026 at 5:25 pm
  • Editorial Team
    Editorial Team added an answer Enums are just named values so you can use them… May 16, 2026 at 5:25 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have an asp button (the code is below). I have the event handler
I have a javascript page which checks an email and username, this works fine
I have this code below which works fine but seems unnecessary as it loops
I have the code below, which works fine it can be viewed for an
I am unable to determine which form submit button is clicked during an Ajax
Hi I have following JavaScript code that I am trying to run. My aim
Question: The JavaScript code below: records is JSON serialized data. I can access it
I have a html page on my localhost - get_description.html . The snippet below
Is there a better way to do this jquery code? Currently I have to
I have a Drupal view which should output a video player using flash. I

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.