Monday, October 22, 2012
Ajax Asynchronous call (VB.NET)
1. declare param type for passing the parameters
Public Class GetRiskParams
Public RISKACCPRIV As String
Public RISKACCCONF As String
Public RISKACCFRAU As String
Public RISKACCAVAI As String
Public RISKACCTPA As String
Public RISKACCDISA As String
Public RISKACCFINA As String
Public RISKACCREGU As String
End Class
2. create a web method in a web service
Public Class MyWebService
Inherits System.Web.Services.WebService
Public Function GetMaxRisk(ByVal params As GetRiskParams) As String
Dim maxRisk As String = String.Empty
Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings.Item("MyConnectionString").ToString())
Dim qryString As String = String.Format("select dbo.GetMaxRisk('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}')", _
params.RISKACCCONF, params.RISKACCFRAU, params.RISKACCAVAI, params.RISKACCTPA, params.RISKACCDISA, params.RISKACCFINA, params.RISKACCREGU, params.RISKACCPRIV)
Using cmd As New SqlCommand(qryString, conn)
conn.Open()
maxRisk = cmd.ExecuteScalar()
End Using
End Using
Return maxRisk
End Function
Public Function IsAppNameDuplicated(ByVal appKey As String, ByVal appName As String) As String
Return "abc"
End Function
End Class
3. calling the web method from javascript client code
function OnChangeRisks() {
var params = new GetRiskParams();
params.RISKACCPRIV = comboRiskPrivacy.GetValue();
params.RISKACCCONF = comboRiskConfidentiality.GetValue();
params.RISKACCFRAU = comboRiskFraud.GetValue();
params.RISKACCAVAI = comboRiskAvailability.GetValue();
params.RISKACCTPA = comboRisk3rdParty.GetValue();
params.RISKACCDISA = comboRiskDisaster.GetValue();
params.RISKACCFINA = comboRiskFinancialReporting.GetValue();
params.RISKACCREGU = comboRiskRegulatoryCompliance.GetValue();
AssetManagementWebService.GetMaxRisk(params, DisplayMaxRisk, OnTimeout);
}
function DisplayMaxRisk(result) {
clientHighestOverallTextBox.SetText(result);
}
function OnTimeout() {
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment