I have a button which when I click, I want to export several CSV files together. But I am not sure how to do that. (I have 'Function1' and 'Function2', when the button is clicked, I want both functions to be called and each of them generates a CSV file)
I have some javascript code to call the functions in the controller:
$('#exportReport').click(function () {
var originalAction = document.forms[0].action;
if (originalAction.indexOf("CorporateProfile") !== -1) {
document.forms[0].action = "/web/admin/configurationreports/Function1";
//document.forms[1].action = "/web/admin/configurationreports/Function2";
document.forms[0].submit();
document.forms[0].action = originalAction;
}
return false;
});
so when the 'exportReport' button is clicked, I want to call both 'Function1' and 'Function2' in the controller
Below is how the 'Function1' look like:
[HttpPost]
public ActionResult Function1(ConfigurationReportsCorporateProfileViewModel viewModel)
{
//inside this I generate a CSV file
var bytes = encoding.GetBytes(stringBuilder.ToString());
return File(bytes, "text/csv", "function1.csv");
}
And I want to call 'Function2' as well but I am not sure how to do that. (would it be something like add to the javascript document.forms.action?)