2

Asp.Net 4.0

In my web applicaion i'm using web service methods. Is it possible to show a popup to request information from a user from a method in the web service?

Oskar
  • 1,597
  • 4
  • 19
  • 38
Troy Mitchel
  • 1,790
  • 11
  • 50
  • 88
  • can you post your code ? – Niventh Mar 19 '13 at 16:56
  • 1
    I suggest you to revise your knowledge regarding application architecture. A web service does not show or call a popup. Have a look at this question: [http://stackoverflow.com/questions/636689/difference-between-frontend-backend-and-middleware-in-web-development](http://stackoverflow.com/questions/636689/difference-between-frontend-backend-and-middleware-in-web-development) – Alberto De Caro Mar 19 '13 at 17:13
  • I figured the web service is just a way to invoke webmethods that returned serialized data, was just wondering about the popup is all. I currently use modalpopupextender in code behind. I was trying to push off some of that to web service. – Troy Mitchel Mar 19 '13 at 17:35

3 Answers3

1

Yes you can use jQuery to call a function of web-service and you can show any popup

शेखर
  • 17,412
  • 13
  • 61
  • 117
1

you can call web methods using jquery, and based on the received data you can show msg box. refer to this for better idea

Community
  • 1
  • 1
Nagaraj
  • 221
  • 2
  • 5
  • 21
0

Without further details about the web service you are invoking, I will give you a quite general example. It requires jQuery.

It assumes that the web service is invoked by some trigger in the client: it could be a user event (click, key press) or a DOM event (load, ready). A handler is assigned to this event. In the case of a button-click event then:

$('#btnCallService').bind('click'
    , {dataObject: 'add evet related data here'}
    , function(event){
        /* here a handler is executed when btnCallService is clicked  */
        callServiceHandler(event.data)
    }
);

Here is the body of the handler, with the call to the service.

function callServiceHandler(eventData) {
    $.ajax({
        type: "GET",
        url: "url_to_your_service_method",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: yourWebMethodArguments,
        success: function (resultData) {
            /* everything is right! result data are available for client side processing and rendering */

            alert('Request completed!');
        }
        error: function (req, status, message) {
            /* something is wrong: guide the user */
            alert('Unable to execute your request: \n' + message);
        },

    });
}

As you can see, the web method calls no popup at all. You could centralize the handler in a library, and call it from every where in your site.

Alberto De Caro
  • 5,147
  • 9
  • 47
  • 73