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

Posted on 2007-08-02
Last Modified: 2013-11-26

     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.
Question by:casstd
    1 Comment
    LVL 4

    Accepted Solution

    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

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now