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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:32:00+00:00 2026-05-24T03:32:00+00:00

I have an asp.net app with an asp:button that causes a postback, this means

  • 0

I have an asp.net app with an asp:button that causes a postback, this means that the html for the input has an onclick attribute that is auto generated, I need to add an event via jQuery to the onclick attribute that fires before the auto generated postback is fired.

Below is an example of the html generated, i need to make sure that my event added by jQuery fires before the WebForm_DoPostBackWithOptions() function.

<input id="ctl00_MainContent_Save" type="submit" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$MainContent$Save", "", true, "", "", false, false))" value="" name="ctl00$MainContent$Save">

for more clarity, I know I can add an event via jQuery like this:

$('#ctl00_MainContent_Save').click(function() {
    somfunction();
});

but i want my event to fire before the WebForm_DoPostBackWithOptions

  • 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-24T03:32:00+00:00Added an answer on May 24, 2026 at 3:32 am

    You can probably try mousedown event which will be fired before the click event is triggered.

    $('#ctl00_MainContent_Save').mousedown(function() {
        somfunction();
    });
    

    or try the below code

    $(document).ready(function(){
    
      $('#ctl00_MainContent_Save')
      .attr("onclick", null)
      .removeAttr("onclick")
      .click(function() {
            somfunction();
            WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions($(this).attr("name"), "", true, "", "", false, false));
        });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET web forms app with a button on it. This button
If I have this asp.net button: <asp:Button ID=Button_Save Width=150px OnClick=Button_Save_Click runat=server Text=Save /> In
I have an ASP.NET app running in IIS that is hosting files all great
I have an ASP.NET app that sits on our intranet, using the WindowsIdentity to
I have an asp.net app that uses System.IO.Path.GetTempFileName() for temporary files. In the production
I have an asp.net mvc app running on a local iis website that is
I have an ASP.NET MVC app that opens a Request view in a new
I have an asp.net mvc app that is built to run as standard web
We have an old asp.net application that has no unit tests, integration tests, component
I have an ASP.NET app that requires users to sign in with their domain

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.