Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

Print an Cert_print.aspx page from a search.aspx page print button clicked. This button will print the cert_print.aspx page during the page of this page


     I have a search listing page. This page result display in a grid. From the records displayed in a grid my user will select more records using checkbox. When the user click on the print button, I pass the ID to a Page called Cert_Print.aspx where I format my to display the required information.

Actually when click on the Print button its calling another page Cert_print.aspx. During the page load of Cert_Print.aspx I have to print this page.
Could anyone help me how to do that in ASP.NET, C# in page load event.
1 Solution
Tommie Nathaniel Carter, Jr., MBACommented:
I would think you would want to print the page only after it is fully loaded so you need to think about moving that functionality to either another c# event or to a javascript function that runs after the page has loaded. The simplest way to get the printout would be to reference the window object from javascript with:


For advanced control of your printing you might try this:

Now a lot of folks have little idea that C# can easily emit HTML, Javascript, CSS, etc. But in fact that is basically all it does with respect to web page production.

In fact printing on the server side seems problematic in other ways. When the C# code is running the page cannot have finished loading. Let me know if you need information on how to emit these other codes but essentially its just the following code placed into the bottom of the window or rewritten as a function and added to the ONLOAD event of the BODY tag of the second page.

Note: Just patched this together on a whim it may have minor syntax errors. But try it and let me know.

Response.Write (@"<script language=\"javascript\">window.print();<\script>")

Be well

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now