我有一个问题是将文本框值传递给更新功能不起作用的控制器。这是我的剧本。
eventDrop: function (event, delta, revertFunc, jsEvent, ui, view) {
if (confirm("Confirm move?")) {
var txtValue = $('#id').val();
var ddlValue = $('#start').val();
$.ajax({
url: '/Booking/Update',
data: { id: txtValue, start: ddlValue },
type: "post",
cache: false,
})
}
else {
revertFunc();
}
},
这是我的控制者。
Function Update(ByVal id As String) As ActionResult
If IsNothing(id) Then
Return New HttpStatusCodeResult(HttpStatusCode.BadRequest)
End If
Dim book As book = dbb.book.Find(id)
If IsNothing(book) Then
Return HttpNotFound()
End If
Return View("Index")
End Function
<HttpPost()>
<ValidateAntiForgeryToken()>
Function Update(<Bind(Include:="id,start,end")> ByVal book As book ) As ActionResult
If ModelState.IsValid Then
dbb.Entry(book ).State = EntityState.Modified
dbb.SaveChanges()
Return RedirectToAction("Index")
End If
Return View("Index")
End Function
该值应传递给update方法并进行搜索。如果匹配id,则应更新起始值。但事实并非如此。我在这里看不到任何错误。有人可以帮忙吗