我遇到了這樣的問題。如何在頁面刷新時傳遞一個字符串?`
場景:
當運行我的行爲我用一個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中檢索它? –