Eamon
asked on
Open file in new window
I have jquery function which calls an action GetReport which returns a pdf file
This is the Action
This is the function
function showReport() {
var clinic = $("#SelectedClinic").val() ;
var date = $("#SelectedDate").val();
var url = "/Reports/GetReport";
$.get(url, { SelectedClinic: clinic, SelectedDate: date }, function (data) {
$("#outPut").html(data);
});
}
This is the result
I would ideally like to open the pdf file in a new window or tab.
I might also like to show the file DIV $("#outPut") but my real question is how to open it in a new window.
By the way this works
@Html.ActionLink("View in new tab","GetReport","Reports" , new {SelectedClinic = "Galway" }, new { target="_blank" })
but i cannot set the SelectedClinic parameter without doing a post.
The SelectedClinic should come from the dropdown.
Thanks
Eamon
This is the Action
return File(renderedBytes, mimeType);
This is the function
function showReport() {
var clinic = $("#SelectedClinic").val()
var date = $("#SelectedDate").val();
var url = "/Reports/GetReport";
$.get(url, { SelectedClinic: clinic, SelectedDate: date }, function (data) {
$("#outPut").html(data);
});
}
This is the result
I would ideally like to open the pdf file in a new window or tab.
I might also like to show the file DIV $("#outPut") but my real question is how to open it in a new window.
By the way this works
@Html.ActionLink("View in new tab","GetReport","Reports"
but i cannot set the SelectedClinic parameter without doing a post.
The SelectedClinic should come from the dropdown.
Thanks
Eamon
You will need to open the new window first and have your script run in that.
ASKER
$("#outPut").html(data);
in a new window will still not display the report.
in a new window will still not display the report.
But why are you doing it this way
Why not just have
<a href="pathtopdf/file.pdf" _target="blank">Link text</a>
Or
<a href="pathtopdfcontainer.h tml" _target="blank">Link text</a> and then have the pdf load in this file (or script)?
Why not just have
<a href="pathtopdf/file.pdf" _target="blank">Link text</a>
Or
<a href="pathtopdfcontainer.h
ASKER
The action GetReport generates the report and returns a file
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
you are welcome - thanks for the points.