如何使word或Pdf文件直接在网页中打开 200分! 一点按钮 直接弹出一个新页 然后里面打开word文件的内容已经保证客户端安装了相应word软件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 完全可以做得到如果你是doc档以文件存在服务器上 <a href = 服务器/档案.doc target = _blank>点这里弹出</a> <a href = 服务器/档案.doc target = _blank>点这里弹出</a> 点击“打开”按钮后,服务器端响应:Response.Write( "<script language=javascript>window.open('WebForm2.aspx')</script>");WebForm2中:private void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) { string filePath = Session["filePath"].ToString(); System.IO.FileStream fs = System.IO.File.OpenRead( filePath ); byte[] FileData = new byte[ fs.Length ]; fs.Read( FileData, 0, (int)fs.Length ); Session.Clear(); Response.Clear(); Response.AddHeader( "Content-Type", "application/vnd.ms-word" ); Response.AddHeader("Content-Disposition", "inline;filename=" + filePath ); Response.AddHeader("Content-Length", fs.Length.ToString() ); Response.BinaryWrite( FileData ); fs.Close(); System.IO.File.Delete( filePath ); } } 忘了说了,第一个页面点击button,事件响应要把文件路径放到session里this.Session["filePath"] = filePath; 楼上的用session干吗?直接通过地址栏文件名就可以了。注意要用urlcode编码 fangxinggood(JustACoder) 说的对 <a href = 服务器/档案.doc target = _blank>点这里弹出</a> 这个就行啊 <a href = ****.doc target = _blank>fasdf</a> 直接的在<A >的href=""写地址就是了。 直接打开.doc的url,或者设置Response.ContentType为word/application,然后再输出word内容 EXT JS2.2 用Request.querystring获得的**.aspx?a=云**参数中的“云”中文是乱码,怎么解决? asp.net 日志问题? GridView中的pagesize 求一sql语句 .net问题 我想隐藏IP的后几位以*号表示,怎样实现? 新手问题,应该很简单,大家帮我看看 模式窗口 怎样回刷datagrid中特定列的值 高手帮忙 高分求教!!:如何通过超链接传递两个以上的参数??? 求个js 本地图片预览功能,兼容性要好点的 图片存储问题 [讨论]我认为应该这样学习.NET 。。。
如果你是doc档以文件存在服务器上
<a href = 服务器/档案.doc target = _blank>点这里弹出</a>
Response.Write( "<script language=javascript>window.open('WebForm2.aspx')</script>");WebForm2中:
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
string filePath = Session["filePath"].ToString();
System.IO.FileStream fs = System.IO.File.OpenRead( filePath );
byte[] FileData = new byte[ fs.Length ];
fs.Read( FileData, 0, (int)fs.Length );
Session.Clear();
Response.Clear();
Response.AddHeader( "Content-Type", "application/vnd.ms-word" );
Response.AddHeader("Content-Disposition", "inline;filename=" + filePath );
Response.AddHeader("Content-Length", fs.Length.ToString() );
Response.BinaryWrite( FileData );
fs.Close();
System.IO.File.Delete( filePath );
}
}
this.Session["filePath"] = filePath;
<a href = ****.doc target = _blank>fasdf</a>