3
Aspx 페이지에서 함수를 만들고이 함수를 Java 스크립트에서 호출합니다. 이제 Java 스크립트를 통해 파일을 다운로드하려고합니다. 그러나 다운로드 대화 상자Javascript에서 다운로드 대화 상자를 여는 방법은 무엇입니까?
..... 열리지 않습니다 Download.Aspx :
string pid = Request.QueryString["Did"].ToString();
DataTable dt;
dt = common.GetFilePath(Convert.ToInt64(pid));
FilePath = dt.Rows[0]["FilePath"].ToString();
FileName = dt.Rows[0]["FileName"].ToString();
FilePath = System.Web.HttpContext.Current.Server.MapPath("~//" + FilePath + "");
Response.Clear();
Response.ClearHeaders();
Response.ContentType = "application/ms-excel";
Response.AddHeader("content-disposition", "attachment; filename=" + FileName + "");
Response.WriteFile(FilePath);
Response.End();
jQuery를 : 당신이 AJAX 호출을하지 않으
function DownloadAttach(pid){
$.ajax({ type: "POST",
url: "http://localhost:1988/DownLoad.aspx?Did=" + pid,
dataType: "xml",
processData: true,
//error: function(XMLHttpRequest, textStatus, errorThrown) { ajaxError(XMLHttpRequest, textStatus, errorThrown); },
success: function(xml) {
//ShowMsg("projSaveMsg", "Attachment Deleted.");
}
});
}
Very Very Tha nxs .... –