is it possible to pass a javascript variable as a parameter to @url.Action(), because as far as i know there may be server and client side issue, my requirement is i have to download the file according to filter, and ajax call doesnot work with downloading the file. so i have harcode the @url.Action() that works but can not able to implement this, can anyone suggest me how to pass the parameter to @url.Action() or any other approach.
here is my code
<a href="@Url.Action("Export", new { SelectedAccountType="1", FromDate = "2014-02-02", ToDate = "2014-02-02", SelectedAccount = "", SelectedUser = "", SelectedTeam = "" })" class="btn-primary" id="exportbutton2"> Export as CSV</a>
and this is the parameter i want to assign to @Url.Action
<script type="text/javascript">
var accountType = $('#SelectedAccountType').val();
var fromDate = $('#FromDate').val();
var toDate = $('#ToDate').val();
var accountId = $('#SelectedAccount').val();
var userId = $('#SelectedUser').val();
var teamId = $('#SelectedTeam').val();
</script>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…