I want to pass value from controller to view in product list of nopcommerce 4.3. So for that I am using ViewData as well as ViewBag, but both are not working. Surprised...!!! but dont know why...??
Here is my Controller code,
[HttpPost]
public virtual IActionResult ProductList(ProductSearchModel searchModel)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
return AccessDeniedDataTablesJson();
//prepare model
var model = _productModelFactory.PrepareProductListModel(searchModel);
ViewData["PersonName"] = searchModel.SearchTotalNetWeight;
return Json(model);
}
And I am doing alerting ViewData in view side in datatable footer action.
function stockfootercallback(tfoot, data, start, end, display) {
alert(@ViewData["PersonName"]);
}
But in alert showing blank value, while as per I am seeing there is not an issue in ViewData syntax, still value is not coming.
I used ViewBag also in the place of ViewData but no use of it.