1
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.

0

2 Answers 2

2

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");
  });
});
Sign up to request clarification or add additional context in comments.

Comments

1
    var id = $('#hdnQuickSalesOrderId').val().trim();

    var url = '@Url.Action("OrderDetailDashboard", "Order", new { orderValue = "__id" })';
    var New =  url.replace("__id", id)
    window.open(New);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.