1
Reply

Open a spread sheet document after downloading automatically

nandini charla

nandini charla

Dec 16 2016 2:12 AM
204
I need to open an open office word document on clicking a button in the browser.To do this what i have done is i had taken a open office spread sheet document in my application folder and i am trying to open that document on button click i had used this code but what happens is it is downloading the document instead i need to open that document.How can i do this.

<asp:ImageButton id="imagebutton1" runat="server"
AlternateText="ImageButton 1"
Image
ImageUrl="images/pict.jpg"
OnClick="imagebutton1_Click"/>

protected void Page_Load(object sender, EventArgs e)
{

}
protected void imagebutton1_Click(object sender, ImageClickEventArgs e)
{
Response.Clear();
Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
Response.AddHeader("Content-disposition", "inline; filename=TestDoc.docx");
String path = Server.MapPath("TestDoc.docx");
Response.WriteFile(path);
Response.End();
}


Answers (1)