I have jQuery creating a form dynamically and adding it to the end of the page it then triggers a submit.
var downloadReportForm = $('<form id="report" action="ReportExcel.aspx" method="POST" />');
downloadReportForm.append(String.format('<input id="{0}" name="{0}" value="{1}" />', "customerGroupId", filter.CustomerGroupID));
$('form').after(downloadReportForm);
downloadReportForm.submit();
The problem is in the ReportExcel.aspx code behind, I don’t get the value for the input. I don’t even see the key for it. It simply isn’t being posted.
I’ve tried GET and POST, and I’ve looked in the Request objects QueryString, Form, and Params lists. Nothing.
I can’t use $.Post() though, since I need the response to come back to this page, as the aspx returns an excel content type, with it’s bytes, and I need the browser to open the download dialog.
Any suggestions how I can get this to work?
String.format do not work in Javascript unless you have wrote your own method.
Try this