我遇到了这样的问题。如何在页面刷新时传递一个字符串?`
场景:
当运行我的行为我用一个int数组来检索基于这些ID的数据。这完美的作品,直到你到达视图。我设法检索数据的罚款,但每当我刷新页面,因为数组是一个复杂的类型,它通过作为空行动。为了解决这个问题,我将数组转换为字符串,并希望将此值传递给页面刷新上的操作。但是到目前为止我尝试过的所有内容都没有提交价值,这个参数肯定会被填充。这我想传递的参数是RPString
操作:
[AuthorizeClientID]
[LoggingFilter]
public ActionResult SupplierReportSelection(int ClientID, int[] ReviewPeriodID, string RPString, int? GroupID, int? SupplierID = null, bool? Backbtn = null, int? StatusCategoryID = null) {
if (TempData["TempReviewPeriod"] != null) {
ReviewPeriodID = (int[])TempData["TempReviewPeriod"];
}
ClaimsBySupplierViewModel SupplierModel = ClaimsBySupplier(ClientID, ReviewPeriodID, SupplierID, GroupID);
ViewBag.client = client;
return View("ClaimsBySupplier", SupplierModel);
}
查看:
@if (Model.ReportData.Any()) {
Model.RPString = string.Join(",", Model.inputReviewPeriodIDs);
Model.RPString = Json.Encode(Model.RPString);
//Removed code which isn't needed
}
如果jQuery是也是一种可能性,只是让我知道。
在第一次成功请求期间数组是如何填充的? –
@WiktorZychla该数组填充了一个下拉列表,这取决于用户单击的值 –
不完全是我的意思。我的问题是:传递给GET请求的查询字符串的列表,还是这是一个POST的列表值?无论如何,你有没有想过只是将它存储在Session中,以便当它为空时,从Session中检索它? –