Hi, i've a simple problem. A minor bug in fact..
I have a page with mp3 listing and a column showing the amount of time a download button has been hit. the code works as follow :
Mp3main.aspx.cs
Page_Load :
GetMp3Info();
BuildTable();
//in BuildTable, I add a button dynamically to each row with a specific ID for the download. When we click on the button, I fire the Download_Click() event. Everything is still alright here.
It's all easy the cheesy. I get the ID, format the string. Send info to the url up to my download page.
The download page :
Okay! So mp3s get listed. download buttons are alright. down_click is fired upon click. Download manager popsup both in IE and FF. songs gets downloaded without having the user to change page. At least he doesn't know about it. Problem : The page won't reload itself at all to reload the amount of downloaded times for a mp3!
Why? Page_Load of mp3main.aspx.cs gets fired BEFORE my download_click event! so it has already built the table :S
If you want a live exemple of what i'm trying to say :
Mp3ULoad
I warn you, it's in french. use account aa/aa and play around as you wish
you'll get in the mp3main as soon as you login. if not, you click on new user
thanks for your help!
I have a page with mp3 listing and a column showing the amount of time a download button has been hit. the code works as follow :
Mp3main.aspx.cs
Page_Load :
GetMp3Info();
BuildTable();
//in BuildTable, I add a button dynamically to each row with a specific ID for the download. When we click on the button, I fire the Download_Click() event. Everything is still alright here.
Code:
private void Download_Click(object sender, ImageClickEventArgs e)
{
const string strDown = "download";
string imageID = ((ImageButton)sender).ID;
imageID = imageID.Substring(strDown.Length, imageID.Length - strDown.Length);
string user = imageID.Substring(0, imageID.IndexOf("-"));
string nomFichier = imageID.Substring(user.Length + 1, imageID.Length - user.Length - 1);
IncrémenterDownload(user, nomFichier);
Response.Redirect("download.aspx" + "?fichier=/music/" + user + "/" + nomFichier);
}
It's all easy the cheesy. I get the ID, format the string. Send info to the url up to my download page.
The download page :
Code:
protected void Page_Load(object sender, EventArgs e)
{
string filepath = Request.QueryString["fichier"];
if (filepath != null)
{
string fullfilepath = Server.MapPath("~/" + filepath);
FileInfo download = new FileInfo(fullfilepath);
if (download.Exists)
{
Response.ClearContent();
Response.AddHeader("Content-Disposition", "attachment; filename=" + '"' + download.Name + '"');
Response.AddHeader("Content-Length", download.Length.ToString());
Response.ContentType = "audio/";
Response.WriteFile(download.FullName);
Response.End();
//Response.Redirect("mp3uloadmain.aspx"); DOESN'T WORK
}
else
lbl_download.Text = "OOPS! Le fichier n'existe plus!";
}
else
lbl_download.Text = "Faut pas esseyer de m'entourlouper...";
}
Okay! So mp3s get listed. download buttons are alright. down_click is fired upon click. Download manager popsup both in IE and FF. songs gets downloaded without having the user to change page. At least he doesn't know about it. Problem : The page won't reload itself at all to reload the amount of downloaded times for a mp3!
Why? Page_Load of mp3main.aspx.cs gets fired BEFORE my download_click event! so it has already built the table :S
If you want a live exemple of what i'm trying to say :
Mp3ULoad
I warn you, it's in french. use account aa/aa and play around as you wish
you'll get in the mp3main as soon as you login. if not, you click on new user
thanks for your help!