我收到成功警报,但更新日期的功能不会运行。我错过了什么这是我第一次尝试这个。 acquiredate和DefendantID都有值。
这是aspx页面上的代码:
<script type="text/javascript">
$(function () {
$("[id*=textboxAcquiredDate]").change(function () {
var AcquiredDate = $(this).val();
var DefendantID = $(this).attr("DefendantID");
$.ajax({
type: "POST",
url: "Defendants.aspx/acquireddate_update",
data: "{'DefendantID' : '" + DefendantID + "', 'AcquiredDate' : '" + AcquiredDate + "'}",
contentType: "application/json;charset=utf-8",
dataType: "json",
error: function (response) {
alert("error.");
},
success: function (response) {
alert("update successful.");
}
});
return false;
});
});
</script>
这是aspx.vb文件中的代码(此函数未运行):
<WebMethod()>
<ScriptMethod()>
Public Shared Sub acquireddate_update(DefendantID, AcquiredDate)
Dim stringCommand As String = "UPDATE dbo.Defendant SET AcquiredDate=@AcquiredDate WHERE DefendantID=@DefendantID;"
Using con As New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("connectionstringdev").ConnectionString)
Dim cmd As New SqlCommand(stringCommand, con)
cmd.CommandType = Data.CommandType.Text
With cmd.Parameters
.AddWithValue("@DefendantID", DefendantID)
.AddWithValue("@AcquiredDate", AcquiredDate)
End With
con.Open()
cmd.ExecuteNonQuery()
End Using
End Sub
答案 0 :(得分:0)
在RouteConfig.vb文件中,我注释掉了这一行:
settings.AutoRedirectMode = RedirectMode.Permanent
现在它正在运作!