Chidi Okeh Chidi Okeh - 1 year ago 148
Javascript Question

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

I have an event called


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
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?

Answer Source

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;" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download