Dear Friend,
Try out this code:-
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim sPrintScript As System.Text.StringBuilder = New System.Text.StringBuilder
sPrintScript.Append("<script type='text/javascript'>").AppendLine("")
sPrintScript.Append("<!--").AppendLine("")
sPrintScript.Append("function printText(elementId)").AppendLine("")
sPrintScript.Append("{").AppendLine("")
sPrintScript.Append("var printContent = document.getElementById(elementId);").AppendLine("")
sPrintScript.Append("var windowUrl = 'about:blank';").AppendLine("")
sPrintScript.Append("var windowName = 'Print' + new Date().getTime();").AppendLine("")
sPrintScript.Append("var sTextToPrint = printContent.innerHTML;").AppendLine("")
sPrintScript.Append("var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=0,height=0');")
sPrintScript.AppendLine("")
sPrintScript.Append("printWindow.document.write(sTextToPrint);").AppendLine("")
sPrintScript.Append("printWindow.document.close();").AppendLine("")
sPrintScript.Append("printWindow.focus();").AppendLine("")
sPrintScript.Append("printWindow.print();").AppendLine("")
sPrintScript.Append("printWindow.close();").AppendLine("").Append("}").AppendLine("")
sPrintScript.Append("// -->").AppendLine("")
sPrintScript.Append("</script>")
If Not ClientScript.IsClientScriptBlockRegistered("printText") Then _
ClientScript.RegisterClientScriptBlock(Me.GetType(), "printText", sPrintScript.ToString)
Button1.Attributes.Add("onclick", String.Format("return printText('{0}');", Me.TextBox1.ClientID))
End Sub
The code is in VB so you have to convert it into C#.
http://www.daniweb.com/web-development/aspnet/threads/161217[
^]
Hope this will help you out. Mark this as your answer if it works