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?
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?
Yes you can use jQuery to call a function of web-service and you can show any popup
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.