Click here to Skip to main content
15,905,558 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Hello,

I am using C# to save a data into database. I want a confirmation page after saving the data on 1st page. In taht page some basic information should be printed and user will able to print that page. How to do this?

1. How to display some data on 1st page to 2nd page?

2. How to allow user to print the data as a confirmation part? in asp.net?
Posted

One way is when the C# is done doing it's saving you can do a redirect to your print page sending alone the values you want displayed to print.
 
Share this answer
 
Comments
BCD23 8-Jan-14 9:18am    
yaa... i have done this by using session. But the values are displayed in lables. how to print those values?
bowlturner 8-Jan-14 9:20am    
What do you mean? the user should be able to print the page, you can even give them a 'Print' button to press. What am I missing?
Please check my answer Solution 4. :)
BCD23 8-Jan-14 9:24am    
for printout there should be some structure na? like a report or something like dat? but i have only .aspx page.
bowlturner 8-Jan-14 9:30am    
Well your choices are to format your aspx page to look pretty, or implement a report of some kind, generate a PDF or use some other report generator. The simplest is to format your aspx, if it's a grid generating a .CSV might work, otherwise it's a bit more work to add others. I used to use PDFSharp to generate PDF reports.
For passing data, you can use Sessions or QueryStrings.
Refer - How to: Pass Values Between ASP.NET Web Pages[^]
Quote:
yaa... i have done this by using session. But the values are displayed in lables. how to print those values?
You just need to place a Print Button in the second aspx page like below.
<button onclick="printPage()">Print this page</button>

Add JavaScript function like...
XML
<script>
function printPage()
{
    window.print();
}
</script>

so, when you click on the Button, it will print all the things showing on that aspx page. As simple as that.

Keep coding. :)
 
Share this answer
 
XML
Try this
Step1:Get all the value you need to print from session.Redirect it to a new html page.
Step2:Add one html page for printing those values
Step3:In html page inside script tag declare a variables and assign values from session
Step4:Add div inside body tag.
Step5:Create html table inside script according to the format you want in printout,and bind all values inside <tr>/<td>
Step6:Inside script tag $("#divid").html(HTML);

HTML will be variable in which table is get created.like
 var HTML = "";
 HTML += "<table id='tableid'>";
 HTML += "</table>";

To get session values in html use below code
if (Session["NAME"] != null)
            {
               var name = Session["NAME"];
            }


Hope this make sense.
 
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