Click here to Skip to main content
16,004,782 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,

i am developing a web application. there is a web page where ...

there is a textbox and a button save...

what i want is textbox value should be saved to word document.. without showing or prompting the user to "open" or "save" and "cancel" button dialog box.

i am using the following code but it shows the dialog box to open or save the document, which i want to avoid.(i.e. i want to save the data directly to the word document) i am using the following code..


PLEASE READ THE UNDERLINE LINE TO UNDERSTAND MY PROBLEM

XML
protected void GenerateDoc(object sender, EventArgs e)
    {
        string strBody = "<html>" +
            "<body>" + " <b>Hello team,<br><br> <table>" +
        "<tr><td colspan=\"2\">Document Detail :-<br><br></td>" +
        "<tr><td>Document Code :</td> <td>" + TextBox1.Text + "</td></tr>" +
        "<tr><td>Document Name :</td> <td>" + TextBox1.Text + "</td></tr>" +
        "<tr><td>Employee Code :</td> <td>" + TextBox1.Text + "</td></tr>" +
           " </table><br>This Document is to inform you all that a new document with the above details has been uploaded to the server</b>" +
                   "<font color=\"blue\"><br><br>Thanks & Regards<br>" + TextBox1.Text + "</font>"+

                   // this is another table
                   "<div>Your name is: <b>" + TextBox1.Text + "</b></div>" +
                "<BR><BR><table border=5><tr><td>1st Cell data</td><td>2nd cell data</td></tr></table>" +


            "</body>" +
            "</html>";


        string fileName = "Demo.doc";

        Response.AppendHeader("Content-Type", "application/msword");
        Response.AppendHeader("Content-disposition", "attachment; filename=" + fileName);
        Response.Write(strBody);



    }



Thanks
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900