How to print a web form (webpage) - ASPMANTRA | Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server AND WCF snippets and tutorial How to print a web form (webpage)

In this tutorial I am going to explain how to print a web form (webpage) in using C# and

Method 1:
<asp:Button ID="btnprint" runat="server" Text="Print" OnClientClick="javascript:window.print()"/>

Method 2:
On button click right the below given code:

C# code:

  protected void btnprint_Click(object sender, EventArgs e)
        Page.ClientScript.RegisterStartupScript(this.GetType(), "Printpage", "javascript:window.print();", true);
    } Code:
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Page.ClientScript.RegisterStartupScript(Me.[GetType](), "Printpage", "javascript:window.print();", True)
    End Sub

What do you think about this article?

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.


method 3: [button onclick="window.print()"/]
you can add bootstrap and a fontawesome icon to pretty it up...
[a class='btn btn-default'>][i class='fa fa-print'][/i] Print[/a]