Hello
I have tried into methods:
1. normal way:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString.Get("formid") != null) { int.TryParse(Request.QueryString.Get("formid"), out formId); hfID.Value = formId.ToString(); DownloadFile(formId); } } }
This way doesn' t work. actually, the file was downloaded, but the current page wasn' t displayed.
2. using Thread.
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString.Get("formid") != null) { int.TryParse(Request.QueryString.Get("formid"), out formId); hfID.Value = formId.ToString(); ThreadStart starter = delegate { DownloadFile(formId); }; //ThreadStart Thread oThread = new Thread(starter); //oThread.IsBackground = true; oThread.Start(); } } }
I got an error in method "DownloadFile", maybe in the new thread, some assemblies were not loaded.
3. use asp.net event: Page_Unload
protected void Page_UnLoad(object sender, EventArgs e) { DownloadFile(formId); //base.OnUnload(e); }
The downloading is working, but problem is the current page doesn' t displayed.
4. use javascript.
First, we need to create a new linkbutton event:
protected void LinkButton1_Click(object sender, EventArgs e) { int.TryParse(hfID.Value, out formId); DownloadFile(formId); }
Second:
<script language="javascript"> $(document).ready(function() { __doPostBack('dnn$ctr599$DocumentFormDownload$LinkButton1', ''); });</script>
When page was completed load, then the js code will be excueted.
The way is working on FF, Chrome, but not on IE.
Actually, it's working on IE, but we just got an notification, see below:
This way is similar with: http://sourceforge.net/projects/emule/files/eMule/0.50a/eMule0.50a-Installer.exe/download
Do you have good way for auto download the file?
Any ideas will be appreciated.