How to call WCF services from JavaScript jQuery and ASP.NET AJAX

First we have to create a webapplication and add to it Ajax enabled WCF service.

Change default DoWork method to accept parameter

[OperationContract]
public string DoWork(string userName)
{
[...]

ModalPopupExtender and “Close” button

ModalPopup control from AjaxControlsToolkit has property CancelControlID which has ID of control to close modal popup. But you can use only one control to close window using this property.

If you need more controls to close the popup, you can easily add they on your page. You need to call hide() method of the control from [...]