Link to home
Start Free TrialLog in
Avatar of kbraju76
kbraju76

asked on

Print web page using asp.net

Hi Expert,

       I have a print button on my aspx page. When the user clicks on the print button, without opening printer-friendly version need to go straight to the printer. user doesn't need to first click view, then click printer-friendly version button.

 Can anyone please help me how can i do this using asp.net and vb.net.

Your help is much appreciated
Raju.
ASKER CERTIFIED SOLUTION
Avatar of caball88
caball88

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NowaY
NowaY

caball88 has it right. An alternative is doing it this way.

You can use this sub to do the printing:

    Public Sub Print()

        System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf)
        System.Web.HttpContext.Current.Response.Write("window.print();" & vbCrLf)
        System.Web.HttpContext.Current.Response.Write("</SCRIPT>")

    End Sub

Then anytime you want to print the screen you just call this in your code:

Print()