所以我有一个问题将一个参数传递给我的控制器。
当我执行Ajax.BeginForm并按如下方式传入时:
<% Using Ajax.BeginForm("MultiProcess", "Orders", New MultiProcessRequestViewModel With {.SearchParams = Model.SearchParams},New AjaxOptions With {.UpdateTargetId = "ordersOutput", .OnSuccess = "afterRead", .LoadingElementId = "readingOrders"})%>
该值显示为&#39; Nothing&#39; 。
但是,如果我只是执行以下操作,则在同一页面上:
<%=New JavaScriptSerializer().Serialize(Model.SearchParams) %>
尝试测量值是否已设置。我可以看到该值确实设置和正确。
整个部分供参考:
<% Using Ajax.BeginForm("MultiProcess", "Orders", New MultiProcessRequestViewModel With {.SearchParams = Model.SearchParams}, New AjaxOptions With {.UpdateTargetId = "ordersOutput", .OnSuccess = "afterRead", .LoadingElementId = "readingOrders"})%>
<%=New JavaScriptSerializer().Serialize(Model.SearchParams) %>
<div>
<%=Html.Hidden("SearchParams", Model.SearchParams) %>
<%=Html.Hidden("Test", "Just in case") %>
<%=Html.DropDownList("Process", Model.Processes)%>
<input type="submit" value="Process selected items" class="FormButton" id="btnMultiProcess" />
<br />
</div>
<% End Using %>
测试和过程两者都有效。以下是参考模型:
Public Class MultiProcessRequestViewModel
Public Property SearchParams As New Orders.OrderSearchFilters
Public Property Process As String
Public Property SelectedItems As New List(Of String)
Public Property Test As String
End Class