有一个asp.net页面,由三个框架组成,左边的框架是一些链接,右边的框架是显示的页面,在右边提供将DataGrid的内容动态生成Excel文件后下载,但下载了文件后,左边的链接就失效了,点击左边的链接不会在右边显示新的页面,请问是什么原因,该如何解决?
代码如下:
leftFrame.aspx: ......
<TR>
<TD onmouseover="this.className='tdfocus'" onmouseout="this.className='tdnml'">
<P><IMG height="7" src="../images/cm.gif" width="14"><asp:hyperlink NavigateUrl="../Right/Gsxx/Main_GsxxQuery.aspx" target="mainFrame" Runat=server> 工伤统计 </asp:hyperlink></P> </TD>
</TR> <TR> <TD onmouseover="this.className='tdfocus'" onmouseout="this.className='tdnml'"> <P><IMG height="7" src="../images/cm.gif" width="14"><A href="../Right/Lkgl/Main_LkglQuery.aspx" target="mainFrame"> 离矿信息 </A></P> </TD>
</TR>
...
代码如下:
leftFrame.aspx: ......
<TR>
<TD onmouseover="this.className='tdfocus'" onmouseout="this.className='tdnml'">
<P><IMG height="7" src="../images/cm.gif" width="14"><asp:hyperlink NavigateUrl="../Right/Gsxx/Main_GsxxQuery.aspx" target="mainFrame" Runat=server> 工伤统计 </asp:hyperlink></P> </TD>
</TR> <TR> <TD onmouseover="this.className='tdfocus'" onmouseout="this.className='tdnml'"> <P><IMG height="7" src="../images/cm.gif" width="14"><A href="../Right/Lkgl/Main_LkglQuery.aspx" target="mainFrame"> 离矿信息 </A></P> </TD>
</TR>
...
解决方案 »
- Environment.OSVersion这个是获取得到服务器端系统信息?迷惑
- 用vs2005做好的网站如何发布到测试空间上?
- IIS里网页不能通过域名访问,高手救我
- 下載附件問題,請大俠幫忙, 報Property evaluation failed錯
- 关于(CheckBox)GridView1.Rows[i].FindControl("CheckBox1")
- 为什么对RadioButtonList的Attributes加不上去。
- DataGrid的问题,大家帮忙呀!~
- 求个高手帮忙设计一个接口~!!!!!!!!!
- 文件下载的地址
- 如何实现类似open dialog 这种控件的功能,或者有这种控件在vs中?
- C#权限控制,无从入手????
- 以编程方式建立的WEB控件怎么实现真正HTML的功能
private void lkbExportToExcel_Click(object sender, System.EventArgs e)
{
SaveDataToExcel();
} public void SaveDataToExcel()
{
Response.Clear();
Response.Buffer= true;
//Response.Charset="GB2312";
Response.Charset = "utf-8";
Response.AppendHeader("Content-Disposition","attachment;filename=Excel Report.xls");
//Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.ClearControls(this.dgdQueryResult);
this.dgdQueryResult.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End(); }
执行了SaveDataToExcel就出现了左边框架的链接无效的问题,请高手帮着看看。
mainFrame.location.href = "...";
attachment意思是强制提示下载框,不过你这个比较麻烦,因为xls是ie认识的文件格式
换成inline会自动打开
这个问题困扰我很久了