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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:00:39+00:00 2026-05-28T02:00:39+00:00

I have a submit button on a page. <asp:Button ID=btnSubmit runat=server Text=Save Test OnClick=btnSubmit_Click

  • 0

I have a submit button on a page.

<asp:Button ID="btnSubmit" runat="server" Text="Save Test" OnClick="btnSubmit_Click"
                                        OnClientClick="return ValidateSaveTest(this);" />

On Javascript, ValidateSaveTest function is called which validates all the fields.

function ValidateSaveTest(Sender) {

            //do some validation, if fails return false from here. else move forward

        var parameters = {};
        parameters["parametersName"] = $("#" + hidTestId).val();

        var succeededAjaxFn = function(result) {
            if (result== true) {
                var isNewVersion = confirm("Confirmation message");
                if(isNewVersion)
                {
                        //Raise server side button click event. Dont call click side event anymore.
                        $("#" + "<%=btnSubmit.ClientID %>").click();
                }
                return false;
            }

        }
        var failedAjaxFn = function(result) { return false; }

            //jquery ajax call
        CallWebMethod("../Service.asmx", "IsTestUsed", parameters, succeededAjaxFn, failedAjaxFn);

        //async call, always return false hence no postback from here.
        //Need waiting unless ajax response is obtained.
        return false;
    }

I need to raise server side button click event from javascript once ajax response is received.

  • 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-28T02:00:39+00:00Added an answer on May 28, 2026 at 2:00 am

    You can get the required JavaScript code from the ClientScriptManager’s GetPostBackEventReference method:

    Returns a string that can be used in a client event to cause postback
    to the server.

    This is normally used for writing the onclick attributes on controls like the <asp:linkButton>, but you can use it in your jQuery callback as well:

    var succeededAjaxFn = function(result) {
      //Raise server side button click event. Dont call click side event anymore.
      <%= Page.ClientScript.GetPostBackEventReference(btnSubmit, String.Empty) %>;
    }
    

    The <%= %> block above will write out the following JavaScript for you:

    __doPostBack('btnSubmit','')
    

    Which in turn will post back the form to the server in such a way that ASP.NET thinks the button was clicked, and so the server-side btnSubmit_Click is triggered.

    Notice that using this method, you can pass in a C# reference to the actual control. You don’t need to worry about its client ID, or the correct name and arguments of the __doPostback() JavaScript function. All that is taken care of by the ClientScriptManager when you call this method.

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

Sidebar

Related Questions

I have the following ASP-Markup: <asp:Button runat=server ID=btnSubmit meta:resourcekey=btnSubmit CssClass=submit OnClick=btnSubmit_Click /> And the
I have small page which has label, DropDownList and a submit button. <div> <asp:label
I have an ASP.NET2.0 web page with a Submit button. When the user clicks,
I have an ASP.NET page with a simple form and a submit button. Upon
I have an ASP.Net page with a usercontrol on it. The submit button for
I have an asp.net button on a web page. The OnClientClick code disables the
Within an ASP.NET AJAX UpdatePanel on my page I have a submit button which
I have a simple aspx page with a few TextBoxes and a submit button.
I have a form in an HTM page that, after pressing the submit button,
I have an asp.net page with a datalist with few textboxes, and a submit

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.