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
You need to build you url using javascript/jquery. In the view change the link to
<a id="export" href=#">Export as CSV</a>
Then in the script
var baseurl = '@Url.Action("Export")';
$('#export').click(function() {
var url = baseurl + '?SelectedAccountType=' + $('#SelectedAccountType').val() + '&FromDate=' + $('#FromDate').val() + '&ToDate=' + $('#ToDate').val() + ...etc
location.href=url;
});
However if your form is marked with FormMethod.Get
, then you can just use a normal submit button and no jquery is required
@using (Html.BeginForm("Export", "yourControllerName", FormMethod.Get))
{
@Html.TextBoxForm(m => m.SelectedAccountType)
....
<input type="submit" value="Export" />
}