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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:49:47+00:00 2026-05-29T13:49:47+00:00

I am working on an asp.net page where I have used JQuery UI dialogue.

  • 0

I am working on an asp.net page where I have used JQuery UI dialogue. This dialogue has a submit button. When I click the submit button dialogue closes. I want to call a Webmethod on it. If method returns ture, then I want to close it otherwise I want to keep it open with error message shown.

[Edited]

    <script>

        jQuery(function () {
            var dlg = jQuery("#dialog").dialog({
                draggable: true,
                resizable: true,
                show: 'Transfer',
                hide: 'Transfer',
                width: 320,
                autoOpen: false,
                minHeight: 10,
                minwidth: 10,
                beforeClose: function () {
                    $.ajax({
                        url: "Default.aspx/GetResult",
                        success: function (response) {
                            if (response == true) {
                                ("#dialog").close()
                            }
                            else {
                                alert('asdasdds');
                            }
                        }
                    });


                    return false; //this will stop dialog box to close
                }
            });
            dlg.parent().appendTo(jQuery("form:first"));
        });

    </script>

 <div id="Result">
        Click here for the time.</div>
    <div id="dialog" style="text-align: left; display: none;">
        <asp:Button ID="btnButton" runat="server" Text="Button" OnClick="btnButton_Click" />
    </div>

how to do it. Please suggest.

Regards,
Asif Hameed

  • 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-29T13:49:48+00:00Added an answer on May 29, 2026 at 1:49 pm

    You can call webmethod using ajax and then act on it conditionally based on the response. Let your webmethod just return true/false and then you can check this value on the client side.

    Execute this code on submit button click and do not close the dialog. Let the success handler decide whether to close it or no.

    $.ajax({
        url: "urlOfTheService.asmx/methodName",
        success: function(response){
            if(response == true){
                //Code to close the dialog
            }
            else{
                //Show the error message
            }
        }
    });
    

    ajax() reference: http://api.jquery.com/jQuery.ajax/

    Update:

    Use open event of dialog box to attach the submit handler to form and execute the above code.

            jQuery(function () {
                var dlg = jQuery("#dialog").dialog({
                    draggable: true,
                    resizable: true,
                    show: 'Transfer',
                    hide: 'Transfer',
                    width: 320,
                    autoOpen: false,
                    minHeight: 10,
                    minwidth: 10,
                    open: function(){
                         $(this).find('form')
                         .unbind('submit')
                         .submit(function(){
                              var $form = $(this);
                              $.ajax({
                                 url: "urlOfTheService.asmx/methodName",
                                 success: function(response){
                                    if(response == true){
                                       //Submit the form
                                       $form.unbind('submit')[0].submit();
                                    }
                                    else{
                                       //Show the error message
                                    }
                               }
                             });
                             return false;
                         });
                    }
                });
                dlg.parent().appendTo(jQuery("form:first"));
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used JQuery within my asp.net page. JQuery is working fine. I could
I am working on asp.net using c#. I have one master page with 3
I am working with an ASP.NET MVC application. I have one master page having
The ASP.net page I am currently working on has a drop down list that
I'm working on a asp.net page and I have several buttons in my page,
I have a field on an asp.net page for which I have used RequiredFieldValidator
I have a Jquery Mobile/ asp.net mvc4 application. After the first page, subsequent pages
I have an ASP.net page used to display server inventory information and the information
I have an asp.net page within which I've used several AJAX controls doing partial
I'm working on an ASP.NET page where I've got 10 entities. I'll call them

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.