I have created a Html page in that i am replacing the string with TextBox values.
Print.htm
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<strong style="font-style: italic; font-family: Monotype Corsiva;">Contact Information
</strong>
<table border="0" cellpadding="0" cellspacing="5">
<tr>
<td>
Name
</td>
<td>
{Name}
</td>
</tr>
<tr>
<td>
City
</td>
<td>
{City}
</td>
</tr>
<tr>
<td>
Phone
</td>
<td>
{Phone}
</td>
</tr>
</table>
</body>
</html>
ASPX:
<form id="form1" runat="server">
<div>
<strong style="font-style: italic; font-family: Monotype Corsiva;">Contact Information
</strong>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
Name
</td>
<td>
<asp:TextBox ID="txtName" runat="server" />
</td>
</tr>
<tr>
<td>
City
</td>
<td>
<asp:TextBox ID="txtCity" runat="server" />
</td>
</tr>
<tr>
<td>
Phone
</td>
<td>
<asp:TextBox ID="txtPhone" runat="server" />
</td>
</tr>
</table>
<br />
<asp:Button Text="Print" OnClick="Print" runat="server" />
</div>
<div style="display: none">
<div id="dvHtml" runat="server">
</div>
</div>
</form>
ASPX.CS:
protected void Print(object sender, EventArgs e)
{
string html = string.Empty;
using (StreamReader reader = new StreamReader(Server.MapPath("~/Print.htm")))
{
html = reader.ReadToEnd();
}
html = html.Replace("{Name}", txtName.Text);
html = html.Replace("{City}", txtCity.Text);
html = html.Replace("{Phone}", txtPhone.Text);
this.dvHtml.InnerHtml = html;
int startIndex = html.IndexOf("table");
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.dvHtml.RenderControl(hw);
string divHTML = sw.ToString().Replace("\"", "'").Replace(System.Environment.NewLine, "");
StringBuilder sb = new StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload = new function(){");
sb.Append("var printWin = window.open('', '', 'left=0");
sb.Append(",top=0,width=1000,height=600,status=0');");
sb.Append("printWin.document.write(\"");
sb.Append(divHTML);
sb.Append("\");");
sb.Append("printWin.document.close();");
sb.Append("printWin.focus();");
sb.Append("printWin.print();");
sb.Append("printWin.close();};");
sb.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString());
}
Namespace:
using System.IO;
using System.Text;
Screenshot

Thank You.