Monday, October 22, 2012

Ajax Synchronous call (VB.NET)

1. create web method in web service

Public Class AssetManagementWebService
    Inherits System.Web.Services.WebService

    
Public Function IsAppNameDuplicated(ByVal appKey As String, ByVal appName As String) As String
Return "abc"
End Function
End Class

2. calling web method in the javascript client code

$.ajax({
type: 'POST',
async: false,
url: 'WebServices/GetMaxRisk.asmx/IsAppNameDuplicated',
data: JSON.stringify({ 'appKey':ASPxTextBoxAppKey.GetValue(), 'appName':'b' }),
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function (msg) {
result = msg.d;
},
error: function(e) {
}
});

if (result != '')
{
ASPxLabel_PopUpError.SetText(result);
ASPxPopupControl_Error.Show();
e.processOnServer = false;
}

No comments: