protected void GenerateMsWordDoc(object sender, EventArgs e)
{
string strBody = "<html>" +
"<body>" +
"<div>Your name is: <b>" + txtName.Text + "</b></div>" +
"<table width="100%" style="background-color:#cfcfcf;"><tr><td>1st Cell body data</td><td>2nd cell body data</td></tr></table>" +
"Ms Word document generated successfully." +
"</body>" +
"</html>";
string fileName = "MsWordSample.doc";
Response.AppendHeader("Content-Type", "application/msword");
Response.AppendHeader ("Content-disposition", "attachment; filename="+ fileName);
Response.Write(strBody);
}
Edit - Removed the extra PRE tag. -Ankur