示例#1
0
        /// <summary>
        /// Event when user select upload picture button. It uploads the picture file to the
        /// App_Data directory and writes the file name for the File Name text box.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void UploadArtistImageButton_Click(object sender, EventArgs e)
        {
            FileUpload FileUploadArtistImage = FormView2.FindControl("FileUploadArtistImage") as FileUpload;

            if (FileUploadArtistImage.HasFile)
            {
                try
                {
                    string filename = Path.GetFileName(FileUploadArtistImage.FileName);
                    FileUploadArtistImage.SaveAs(Server.MapPath("~/Images/") + filename);
                    lblErrorArtist.Text = "Artist Image Upload status: File uploaded!";
                    SiteDL.UpdateArtistImagePath(filename);
                    FormView2.DataBind();
                }
                catch (Exception ex)
                {
                    lblErrorArtist.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                }
            }
            else
            {
                lblErrorArtist.Text = "Could not find file";
            }
            upPayPal.Update();
        }
示例#2
0
 /// <summary>
 /// Event when user select Upload Logo File  button. It uploads the picture file to the
 /// Images directory and writes the file name for the File Name text box and updates that column
 /// in the database.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void UploadLogoButton_Click(object sender, EventArgs e)
 {
     if (FileUploadLogo.HasFile)
     {
         try
         {
             string filename = Path.GetFileName(FileUploadLogo.FileName);
             FileUploadLogo.SaveAs(Server.MapPath("~/Images/") + filename);
             ErrorLabel.Text = "Upload status: Logo File uploaded!";
             SiteDL.UpdateLogoPath(filename);
             FormView1.DataBind();
         }
         catch (Exception ex)
         {
             ErrorLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
         }
     }
     else
     {
         ErrorLabel.Text = "Could not find file";
     }
     upPayPal.Update();
 }