How to I redirect to another page *after* printing document?

I have an event called SubmitResponse().

A user is presented with a list of questions and possible responses. After completing the responses, the user clicks the Preview button. If responses are correct, the user clicks the SubmitResponse button and then SubmitResponse() processes it.

Upon clicking the SubmitResponse button, a print screen pops up for the user to print a copy. This is the calling code for the JS print feature.

finsub.Attributes.Add("OnClick", "print_form()")

Works fine but there is one problem. We would like the user to be redirected to the screen that displays results of his/her response with the code below.

What is happening is that once the user clicks the submitResponses button, s/he is immediately redirected to the results.aspx page and the print feature is no longer available.

Is there a way to work around this?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You can do the printing and redirect all via javascript. Here is an example that should work:

function doPrint() {
    document.location.href = "Somewhere.aspx"; 

Link it to a Button:
<asp:Button ID="btnPrint" runat="server" Text="Print"
    OnClientClick="doPrint(); return false;" />

Method 2

For cross browser compatibility, you need to introduce a delay between the window.print() call and the redirect.

I find the following works well (using JQuery framework to print a page as soon as it loaded):

 <script type="text/javascript">
    $(document).ready(function () {
        setTimeout("closePrintView()", 3000);
    function closePrintView() {
        document.location.href = 'somewhere.html';

This can be easily adapted for “Print” buttons and links etc.

Method 3

you can use this code :

window.onafterprint = function(event) {
    window.location.href = 'index.php'

using window.print() callBack!!

Method 4

Redirect on client side using javascript/jQuery


For your case
 insub.Attributes.Add("OnClick", "print_form();window.location.href='results.aspx';")

Method 5

<script type="text/javascript">window.location = 'url.aspx';</script>

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x