私はこのコードを使用しています:
$("#dropdownPaper").change(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "NomexLine500A.aspx/CalcBlockCode",
data: "{}",
dataType: "json",
success: function (data) {
$("#textBlockCode").text(data.d)
},
error: function (result) { }
});
});
ドロップダウンリストの変更に応答して、aspx ページの分離コード ファイルで関数を実行します。
コードビハインドの関数は次のとおりです。
Protected Function CalcBlockCode() As String
Dim strReturn As String
Dim paper As New DropDownList
Dim cylinder As New DropDownList
'Dim blockcode As New TextBox
paper = FormView1.FindControl("dropdownPaperItem")
cylinder = FormView1.FindControl("dropdownCylinderNumber")
'blockcode = CType(FormView1.FindControl("textBlockCode"), TextBox)
If paper.Text = "" Or paper.Text = "None" Then
CalcBlockCode = "NA"
Exit Function
End If
If cylinder.Text = "" Or cylinder.Text = "None" Then
CalcBlockCode = "NA"
Exit Function
End If
Dim strCellSizeCode As String
Dim intMil As Decimal
Dim strCylinderID As String
strCellSizeCode = DLookup("CellSizeCode", "Cylinders", "CYLINDERS = '" & cylinder.Text & "'")
intMil = DLookup("Mil", "PaperPart", "ITEM_NBR = '" & paper.Text & "'")
strCylinderID = DLookup("CylinderID", "Cylinders", "CYLINDERS = '" & cylinder.Text & "'")
strReturn = Convert.ToInt32(intMil * 10) & strCellSizeCode & strCylinderID
CalcBlockCode = strReturn
End Function
Firefox Web ツールでは、jquery 関数が実行されているという証拠は見当たりません。実行された場合、戻り値が得られません。コードビハインドから関数を取得するための ajax 呼び出しの正しい URL を参照していますか?