I have a Web User Control containing a FormView
. The formview shows details of job seeker. I have provided a button for "Download Resume" link, so that admin/HR can download the resume. I have placed this control in an aspx page that contains the UpdatePanel. Everything works fine except Download Link.
I have given a Command on donwload link button and a function is associated with the command to start download.
Below is the code i have implemented -
//Command on 'Download' link button within FormView
protected void lnkDownload_Command(object sender, CommandEventArgs e)
{
if (e.CommandName.Equals("Download"))
{
StartDownload(e.CommandArgument.ToString());
}
}
//My routine to download document
//sFileInfo contains filepath$==$mimetype
protected void StartDownload(string sFileInfo)
{
string[] d = sFileInfo.ToString().Split((new string[] { "$==$" }), StringSplitOptions.None);
string filename = d[0];
string docType = d[1];
System.IO.FileInfo file = new System.IO.FileInfo(d[0]);
if (file.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + d[0]);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = d[1];
Response.WriteFile(file.FullName);
Response.End();
}
else
{
Server.Transfer("~/Mesgbox.aspx?cat=2");
}
}
The code works perfectly if update panel is removed but generates script errors if update panel is used.
Any suggestions....?
Thanks for sharing your time.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…