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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:28:59+00:00 2026-06-18T05:28:59+00:00

I`m using Javascript function that uses a web service and after finishing it i

  • 0

I`m using Javascript function that uses a web service
and after finishing it i have to update a Grid Datasource

To accomplish this task i called the javascript function via RegisterClientScriptBlock then call the UpdateGridDataSource method

But While Debugging i found that it calls the UpdateGridDataSource method first ..
Then Call the method in the WebService!

ASP.Net Code

System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "delete", "DrawPOI();", true);

UpdateDataSource(); 

JavaScriptCode

function DeletePOI(arg) {
      //Some Code  
        $.ajax({
            url: "JSBLL.asmx/DeletePOI",
            type: "POST",
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            data: "{id:'" + arg + "'}",
            success: function (msg) {
                alert(msg.d);
            },
            error: function (e) {
                alert('Error');
            }
        }); //some code
        return false;
    }

WebService :

[WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public string DeletePOI(string ID)
        try
            {
                if (id == "")
                    throw new Exception();

                long ID = Convert.ToInt64(id);
                using (GuardEntities database = new GuardEntities())
                {
                    var poi = database.POIs.Where(x => x.ID == ID).FirstOrDefault();

                    database.POIs.DeleteObject(poi);
                    database.SaveChanges();
                }

                return "POI Deleted Successfully";
            }
            catch
            {
                return "Error Occured";
            }
}

The Problem is that UpdateDataSource() is called before DeletePOI(string ID)

  • 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-06-18T05:29:00+00:00Added an answer on June 18, 2026 at 5:29 am

    Javascript code registered with RegisterClientScriptBlock() runs on the client in the browser. ASP.NET code runs on the server.

    When it gets to the line:

    System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "delete", "DrawPOI();", true);
    

    It says, when the page loads on the client, call DrawPOI(). It then immediately runs the next line of code:

    UpdateDataSource(); 
    

    When it’s done with all the ASP.NET code, it then sends your page to the client. Basically, what you are trying to do will not work. You can’t call client-side Javascript in the middle of your server-side ASP.NET code and wait for it to return.

    What you can do is call the web service directly from your server-side code.

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

Sidebar

Related Questions

I have a canvas that I am using a javascript function to display text
I have a variable that I'm using to build a JavaScript function call, and
Possible Duplicate: Consuming a Web service using Javascript Please note that I'm still getting
I have a web site I created that uses Python, HTML, and javascript. The
I want to execute any JavaScript function that is part of a JSON using
I need to write, in JavaScript (I am using jQuery), a function that is
I'm using a javascript function to submit my form. This works in every browser
I am using this JavaScript function in order to change image on click, but
I have searched this web looking for an answer, but it seems that this
I'm building an web app that uses this code to search for addresses: http://code.google.com/intl/en/apis/maps/documentation/javascript/examples/places-autocomplete.html

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.