protected void LinkButton1_Click1( object sender , EventArgs e )
{
int row = ( (GridViewRow)( (LinkButton)sender ).NamingContainer ).RowIndex;
string wenname = subll.getgnamebyid( Convert.ToInt32( grshow.Rows[row].Cells[0].Text ) );
string filename = Server.MapPath( "~/" + subll.getway( Convert.ToInt32( grshow.Rows[row].Cells[0].Text ) ) );
DownLoad( wenname , filename );
}
private void DownLoad( string strName , string strPath )
{
string fileName = strName;//客戶端保存的文件名
FileStream fs = new FileStream( strPath , FileMode.Open );
byte[] bytes = new byte[(int)fs.Length];
fs.Read( bytes , 0 , bytes.Length );
fs.Close( );
Response.ContentType = "application/octet-stream";
//通知瀏覽器下載文件而不是打開
Response.AddHeader( "Content-Disposition" , "attachment; filename=" + HttpUtility.UrlEncode( fileName , System.Text.Encoding.UTF8 ) );
Response.BinaryWrite( bytes );
Response.Flush( );
Response.End( );
}
點(diǎn)擊linkbutton老是下載自己的這個(gè)aspx頁面 不知道怎么回事。谷歌? 火狐 沒問題 求解釋 ie8.。。什么的都有問題
- 9 回答
- 0 關(guān)注
- 467 瀏覽
添加回答
舉報(bào)
0/150
提交
取消