I have a page in MVC2 containing a grid button and images. When the image button is clicked, the current page, orderBy and filter will be sent to the controller in jQuery. The code:
<script type="text/javascript"> $("#ExportExcel").click(function (e) { e.preventDefault(); var resourceId = $('#resourceId').val(); var grid = $('#Grid').data('tGrid'); var pagenum = grid.currentPage; var orderBy = grid.orderBy var filter = grid.filterBy; $.ajax({ url: '@Url.Action("ExportToExcel", "ExportExcelButton")', data: { resourceId: resourceId, pagenum: pagenum, orderBy: orderBy, filter: filter }, type: 'POST', success: function (data) { } }); }); </script> <a href="<%: Url.Action("ExportToExcel", "ExportExcelButton") %>"> <img src='<%: Url.Content("~/Content/Images/ExportExcelButton.gif") %>'/></a> public ActionResult ExportToExcel(string resourceId, string pagenum, string orderBy, string filter)
However, when you click the image button, all data is null in the ExportToExcel action. I wonder how to do it right. Thank you very much.
source share