本文介绍了在新视窗中开启档案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好, 作为我上一篇文章的解决方案," 文件未打开. [ ^ ] 我发现此代码打开了我想要的pdf文件,但是我想要在新页面中打开它? 我的代码是;
Hello all, As a solution to my previous post ""Files are not opening.[^] I found this code which opens the pdf file that I want but what I want is to open this in a new page? My code is;
string fileToRenamePath = RMAConfig.PDFPath + "Return Documentation [ " + this.rmaObjSum.RMANum + " ]" + RMAConfig.Extension; // The valeu for fileToRenamePath here is : C:/RMA/Returns/Return Documentation[3232-32326].pdf WebClient client = new WebClient(); Byte[] buffer = client.DownloadData(fileToRenamePath); if (buffer != null) { Response.ContentType = "application/pdf"; Response.AddHeader("content-length", buffer.Length.ToString()); Response.BinaryWrite(buffer); }这将在当前浏览器中打开文件.
This open the file in the current browser.
推荐答案这可能有用. This might work. Response.Write("<script>window.open('file.pdf',target='new');</script>")
编辑================ 好吧,我放弃.为什么要进行1票表决?
EDIT ================ Okay, I give up. Why was this 1-voted?
U可以使用target = _blank属性,将其作为新窗口打开 EG: Hi, U can Use target=_blank property which will open it as new window EG: Response.Write("<script>window.open(''www.google.hk/'',''_blank'');</script>");
快乐编码
Happy Coding
更多推荐
在新视窗中开启档案
发布评论