求教:LinkButton与网页对话框的问题
我有一段下栽文件的代码,如下:
public void DownLoadFile(string FileName,string strAbsolutePath)
{
System.IO.Stream iStream = null;
byte[] buffer = new Byte[10000];
int length;
long dataToRead;
string filepath = strAbsolutePath;
try
{
iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open,System.IO.FileAccess.Read,System.IO.FileShare.Read);
dataToRead = iStream.Length;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" +HttpUtility.UrlEncode(FileName));
while (dataToRead > 0)
{
if (Response.IsClientConnected)
{
length = iStream.Read(buffer, 0, 10000);
Response.OutputStream.Write(buffer, 0, length);
Response.Flush();
buffer= new Byte[10000];
dataToRead = dataToRead - length;
}
else
{
dataToRead = -1;
}
}
}
catch (Exception ex)
{
Response.Write("Error : " + ex.Message);
}
finally
{
if (iStream != null)
{
//Close the file.
iStream.Close();
}
}
}
我是将这些功能做在了usercontrol里。
(在DataGrid里的模板列里放了一个LinkButton,使它的click事件执行这段代码)
普通的页面使用这个usercontrol都是可以的,没有任何问题。但是我的实际应用需要的是在网页对话框里调用这段代码。
不知道是什么原因却不行,而且如果我点击了这个LinkButton后其他的LinkButton也失效了。
还请高手指教