0

im trying to open a document...but every time i get a dialoge box asking if i want to pen,save or cancel.i just want to open the document.can someone tell me wot im doing wrong?here's my code

if (objView.extension == ".pdf" || objView.extension == ".xls" || objView.extension == ".xlsx" || objView.extension == ".doc" || objView.extension == ".docx")
            {
                System.Data.DataSet dsImg = new System.Data.DataSet();
                dsImg = objView.getBinaryData();
                Response.ContentType = "application/Octet-stream";
               
                Response.AddHeader("content-disposition",
                                               "attachment;filename="+ filename);
                Response.Charset = "";
                Response.Cache.SetCacheability(HttpCacheability.NoCache);

              
                foreach (System.Data.DataRow dr in dsImg.Tables[0].Rows)
                {
                    Response.BinaryWrite((byte[])dr[0]);
                }

                dsImg.Dispose();
                objView.Close();

                Response.End();

            }
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Ketsuekiame
0

Ok what you're doing is actually setting the file for download in the browser. If you want to open the file on the server machine then use the File class and the StreamReader/Writer classes.

If you want to open the file on the client machine, then you will probably need to use ActiveX, but I don't know anything about that. You may find it better asking this question on the ASP forums.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.