My web page contains two button i.e
Collapse | Copy Code
when i click on the OpenFile Button i need to open the word document and also below the Next button should visible to the user.
so i write some code but it's working to open the word document, but it's not visible the Next button to the user.
Collapse | Copy Code
btnNext.Visible = true;
FileInfo file = new FileInfo("filename.doc");
Response.ClearContent();
Response.AddHeader("Content-Disposition", "inline;filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/msword";
Response.TransmitFile(file.FullName);
Response.End();
Plese give me solution it's urgent.
Thanks ,
Suresh
John GlennPosted Mar 2, 2012, 6:24 AM
here is a sample ASP.NET export to Word code with this C# / VB.NET Word component. Hope it helps!
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
// Create a new empty document.
DocumentModel document = new DocumentModel();
// Add document content.
document.Sections.Add(new Section(document, new Paragraph(document, "Hello World!")));
// Microsoft Packaging API cannot write directly to Response.OutputStream.
// Therefore we use temporary MemoryStream.
using (MemoryStream documentStream = new MemoryStream())
{
document.Save(documentStream, SaveOptions.DocxDefault);
// Stream file to browser.
Response.Clear();
Response.ContentType = "application/vnd.openxmlformats";
Response.AddHeader("Content-Disposition", "attachment; filename=Document.docx");
documentStream.WriteTo(Response.OutputStream);
Response.End();
}