Click here to Skip to main content
15,887,436 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
form1.axpx

I have print button .

form2.aspx

I have a
ASP.NET
<asp:Label ID="Label1" runat="server" Text="name"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>


If user clicks print button from form 1 I need to print aspx2 data.

What I have tried:

HTML
   <script type="text/javascript">
         function PrintPage() {
             if (window.confirm("will you print his page?")) {
                 window.print();
             }
             //dosomething();}
            
         }
</script>
Posted
Updated 17-Feb-16 1:37am
v2
Comments
Kornfeld Eliyahu Peter 17-Feb-16 7:47am    
You have a serious hole in your knowledge about how web application works...
You must go back to the roots and learn about the stateless (disconnected) nature of the web, about the client/server architecture, and after that about printing inside browsers...
ZurdoDev 17-Feb-16 9:01am    
Your js will print the current window. So that code needs to go into form2. Form1 can open form2 and then in form2 use jquery's document.ready to then prompt for printing.

1 solution

I'm not getting the correct idea of what you are trying to do. But let me suggest a solution.

You don't need to have Form 2. Assuming that you are not showing the Form 2 to the user, you can have the text box and the label in the same from 1 and hide them. So when you hit the button, you can print that hidden part (label and the text box) JS and CSS Media Queries (Search internet on the CSS Media Queries).

Please let me know if this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900