Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
81
rated 0 times [  88] [ 7]  / answers: 1 / hits: 28313  / 13 Years ago, wed, october 19, 2011, 12:00:00

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.



Response.Redirect(results.aspx)


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?


More From » asp.net

 Answers
128

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



function doPrint() {
window.print();
document.location.href = Somewhere.aspx;
}


Link it to a Button:



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

[#89527] Tuesday, October 18, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
theodore

Total Points: 318
Total Questions: 97
Total Answers: 119

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
;