window.location = '@Url.Action("PrintReport", "Report")?from=' + $("#fromDate").val() + '&to=' + $("#toDate").val();
How could i open it at new tab? I call it in JavaScript against a click.
Depending on WHAT you click have
var url = '@Url.Action("PrintReport", "Report")?from=' +
$("#fromDate").val() + '&to=' + $("#toDate").val();
window.open(url,"_blank")
or better: have a link with target="_blank" -
<a href="#" target="_blank"
onclick="this.href='@Url.Action("PrintReport", "Report")?from=' +
$("#fromDate").val() + '&to=' + $("#toDate").val();">Print</a>
Or unobtrusive:
<a href="#" id="printReport" target="_blank" >Print</a>
using
$(function() {
$("#printReport").on("click",function(e) {
$(this).attr("href",'@Url.Action("PrintReport", "Report")?from=' +
$("#fromDate").val() + '&to=' + $("#toDate").val());
});
});
or both:
$(function() {
$("#printReport").on("click",function(e) {
e.preventDefault();
window.open('@Url.Action("PrintReport", "Report")?from=' +
$("#fromDate").val() + '&to=' + $("#toDate").val(),"_blank");
});
});