ユーザーがカートにアイテムを追加できる MVC アプリを作成しています。また、特定のアイテムの一部を支払うこともできるので、支払い額を指定するための TextBox があります。Ajax ActionLink を使用して更新/カートへの追加アクションを処理しているため、部分ビューを使用して画面を更新せずにカートの数を増やすことができます。私の問題は、TextBox に入力された値を PartialViewResult 関数に渡したりアクセスしたりする方法が見つからないことです。
これが私のモデルです...
Public Class StudentSchoolFee_Transaction
Public Property SchoolFeeId As Integer
Public Property Title As String
Public Property Price As Decimal
Public Property AmountDue As Decimal
<DisplayFormat(ApplyFormatInEditMode:=True, DataFormatString:="{0:C2}")>
Public Property Amount As Decimal
Public Property Description As String
Public Property AcceptPartialPayment As Boolean
Public Property StudentId As Integer
Public Property TransactionId As Integer
End Class
Public Class AssignedFeesModel
Public Property StudentId As Integer
Public Property StudentNumber As Long
Public Property SiteId As String
Public Property SelectedSchoolFeeId As Integer
Public Property SelectedAcceptPartial As Boolean
Public Property SelectedAmountDue As Decimal
Public Property SelectedAmount As Decimal
Public Property SelectedTransactionId As Integer
Public Property AssignedFeesCol As System.Collections.Generic.List(Of StudentSchoolFee_Transaction)
Public Sub New()
End Sub
Public Sub New(ByVal _Deliver As EMS.Grid.Deliver, ByVal _StudentId As String)
Dim SelectedStudent As New Library.Student(_Deliver, _StudentId)
AssignedFeesCol = New System.Collections.Generic.List(Of StudentSchoolFee_Transaction)
StudentId = SelectedStudent.Id
StudentNumber = SelectedStudent.StudentNumber
SiteId = SelectedStudent.SiteId
'Load AssignedFeesCol
End Sub
End Class
これが私の最初の読み込み ActionResult と私の AddAssignedFee PartialViewResult で、カートの数を更新します...
Function AssignedFees(ByVal StudentId As String, Optional ByVal ErrorMessage As String = "") As ActionResult
Dim oDeliver As New EMS.Grid.Deliver
oDeliver.UDLNameOrConnString = ConfigurationManager.ConnectionStrings("DefaultConnection").ConnectionString
Dim m As New AssignedFeesModel(oDeliver, StudentId)
Dim stu As New Library.MealHistoryDB.Student(oDeliver, m.StudentNumber, UserSession.GetSession.DistrictId)
Return View(m)
End Function
Public Function AddAssignedFee(ByVal StudentId As Integer, ByVal SchoolFeeId As Integer, ByVal SelectedAmount As Decimal) As PartialViewResult
Dim oDeliver As New EMS.Grid.Deliver
oDeliver.UDLNameOrConnString = ConfigurationManager.ConnectionStrings("DefaultConnection").ConnectionString
With New Library.Ecommerce.SchoolFee(oDeliver, SchoolFeeId)
.AddToCart(oDeliver, UserSession.GetSession.ParentId, StudentId, SelectedAmount)
End With
Return PartialView("_CartButton") ', New Global.MSM.mobile.CartButton())
End Function
そして、ここに私のAjaxアクションリンクがあります.1つ目は、金額が指定されていないアイテムを追加するためのもので、機能します。2 つ目は、部分的な支払い金額を持つことができるアイテムを更新するためのもので、金額を PartialViewResult に渡す方法が見つかりません。
@Ajax.ActionLink("Add", "AddAssignedFee", "Parent", New With {.StudentId = currentItem.StudentId, .SchoolFeeId = currentItem.SchoolFeeId, .SelectedAmount = currentItem.Amount}, New AjaxOptions() With {.HttpMethod = "POST", .InsertionMode = InsertionMode.Replace, .UpdateTargetId = "btnCartContainer"}, New With {.class = "button"})
@Ajax.ActionLink("Update", "AddAssignedFee", "Parent", New With {.StudentId = currentItem.StudentId, .SchoolFeeId = currentItem.SchoolFeeId, .SelectedAmount = currentItem.Amount}, New AjaxOptions() With {.HttpMethod = "POST", .InsertionMode = InsertionMode.Replace, .UpdateTargetId = "btnCartContainer"}, New With {.class = "button"})
Update リンクに対して ".SelectedAmount = Model.SelectedAmount" も試しましたが、入力した Amount を PartialViewResult に渡す方法が見つからないようです。
助言がありますか?
ありがとうございました!リンジー