Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi all,

i was wondering if anyone had a quick solution to have a button click to pass values from aspx web form to a word.dot
i have a button that opens my template but i would like it to pass textbox.text to book marks in the word template

e.g
textbox1.text = bookmark.ID
textbox2.text = bookmark.Fname
textbox3.text = bookmark.Lname
textbox4.text = bookmark.Address ext...

C#
protected void Button7_Click(object sender, EventArgs e)
    {
        string fPath = @"\\Server12\170912.dot";
        FileInfo myDoc = new FileInfo(fPath);
        Response.Clear();
        Response.ContentType = "Application/msword";
        Response.AddHeader("content-disposition", "attachment;filename=" + myDoc.Name);
        Response.AddHeader("Content-Length", myDoc.Length.ToString());
        Response.ContentType = "application/octet-stream";
        Response.WriteFile(myDoc.FullName);
        Response.End();
      }


Thank you in advance as always
Posted
Updated 1-Oct-13 1:57am
v2
Comments
JoCodes 1-Oct-13 8:50am    
Try something like
object
objBookMark = "BookMark";
objWordDoc.Bookmarks.Item(objBookMark).Range.Text = textbox1.Text;
roufghrider 1-Oct-13 10:03am    
thanks for that but i have no idea how to input that to the existing code above, i get the objWordDoc does not exist in current context.

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