I have page in MVC2 that contain a grid and image button. When image button is clicked, the currentPage, orderBy and filter will be posted to a controller in JQuery. The code is,
<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 image button is clicked, all data are null in ExportToExcel action. I wonder what is the right way to do it. Thanks a lot.