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

  • Home
  • SEARCH
  • 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

Related Questions

I have a working JavaScript code below which dynamically creates JSON object using JSON.parse
I develop in ASP.NET MVC3, I have the code below to send the view
I have this javascript code below that uses jquery, it is suppoed to be
I have a dialog box, created with the code javascript and HTML generated below.
I have an issue in my JavaScript function. Below is my js code: function
I have JavaScript code which copies the value of input file and paste it
I have this code below which works fine but seems unnecessary as it loops
I have a javascript function which get datagrid's header into THEAD tags. This code
I have the below code which prints out the date which is 10 working
I have the following javascript code in place which is used to give hover

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.