In
this tutorial I am going to explain how to print a web form (webpage) in
asp.net using C# and VB.net
In
the previous article I have explained how to generate and display QR code imageusing QR Code library in asp net, how to Bind comma separated values to listboxin asp.net in ASP.Net using C# and VB.net, how to get comma separated values(data) from database and bind to checkboxlist in ASP.Net and how to insertmultiple selected items of Listbox to database as comma separated in ASP.Net.
Implementation:
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);
}
VB.net
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
method 3: [button onclick="window.print()"/]
ReplyDeleteyou can add bootstrap and a fontawesome icon to pretty it up...
[a class='btn btn-default'>][i class='fa fa-print'][/i] Print[/a]