protected void UploadButton_Click(object sender, EventArgs e) { FileUpload FileUpload1 = (FileUpload)this.FormView1.FindControl("FileUpload1"); Label FileUploadLabel1 = (Label)this.FormView1.FindControl("FileUploadLabel1"); Label FileExtLabel1 = (Label)this.FormView1.FindControl("FileExtTextBox_Insert"); Label NextDocVersIDLabel = (Label)this.FormView2.FindControl("NextDocVersIDLabel"); //int New_or_Replace = this.FormView1.FindControl("RadioButtonList1"); // string path = ConfigurationManager.AppSettings["DOCUMENT_LOCATION"]; string path = @"\\autism-fs01\d$\WebDocs\"; bool fileOK; fileOK = false; // Before attempting to perform operations // on the file, verify that the FileUpload // control contains a file. if (FileUpload1.HasFile) { String NextDocVersID = NextDocVersIDLabel.Text; String filePath = System.IO.Path.GetFullPath(FileUpload1.FileName); String fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower(); String[] allowedExtensions = { ".doc", ".pdf", ".txt", ".xls", ".gif", ".png", ".jpeg", ".jpg", ".bmp", ".sps", ".sav", ".spo", ".rtf" }; for (int i = 0; i < allowedExtensions.Length; i++) { if (fileExtension == allowedExtensions[i]) { fileOK = true; } } if (fileOK) { try { ((Label)FormView1.FindControl("FileExtTextBox_Insert")).Text = fileExtension; //((Label)FormView1.Row.Cells[0].FindControl("FileUploadLabel1")).Text = FileUpload1.FileName; FileUpload1.PostedFile.SaveAs(path + "DocVersID_" + NextDocVersID + fileExtension); MessageBox2.Show("File uploaded."); } catch (Exception ex) { // ((Label)FormView1.Row.Cells[0].FindControl("FileUploadLabel1")).Text = "File could not be uploaded."; MessageBox2.Show("ERROR: File could not be uploaded."); } } else { MessageBox2.Show("Cannot accept files of this type."); } } }
protected void GiftCertificatesGridView_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e) { string key = (string)GiftCertificatesGridView.DataKeys[e.RowIndex].Value; if (key != string.Empty) { if (MTApp.DestroyProduct(key)) { MessageBox1.ShowOk("Gift certificate was deleted successfully"); MessageBox2.ShowOk("Gift certificate was deleted successfully"); } else { MessageBox1.ShowError("An error occurred while trying to delete the gift certificate"); MessageBox2.ShowError("An error occurred while trying to delete the gift certificate"); } } BindGiftCertificateGridView(); e.Cancel = true; }
protected void SaveLocal_Button_Click(object sender, EventArgs e) { if (Request.Params["DocVersID"] != null) { //Response.TransmitFile("\\autism-fs01\d$\WebDocs\DocVersID_" + DocVersID + ViewState["fileext"].ToString()); String serverfilenameandpath = (@"\\autism-fs01\d$\WebDocs\DocVersID_" + Request.Params["DocVersID"] + ViewState["fileext"].ToString()); String localfilename = "DocVersID_" + Request.Params["DocVersID"] + ViewState["fileext"].ToString(); try { Response.TransmitFile(serverfilenameandpath); Response.AppendHeader("Content-Disposition", "attachment; filename=" + localfilename); Response.End(); } catch (Exception ex) { // ((Label)FormView1.Row.Cells[0].FindControl("FileUploadLabel1")).Text = "File could not be uploaded."; MessageBox2.Show("ERROR: File could not be saved. (" + ex.Message + ")"); } } }
protected void EditDocumentInfo_Submit(object sender, EventArgs e) { HtmlControl theframe1 = (HtmlControl)this.Master.FindControl("oBodyPlaceHolder").FindControl("frame1"); //theframe1.Attributes["src"] = @"\\autism-fs01\d$\WebDocs\DocVersID__ReplacingFileNotice.htm"; //HtmlControl frame1 = (HtmlControl)this.FindControl("frame1"); // edit the following to replace the file // FileUpload FileUpload2 = (FileUpload)this.FormView1.FindControl("FileUpload2"); Label FileUploadLabel2 = (Label)this.FormView1.FindControl("FileUploadLabel2"); Label FileExtLabel2 = (Label)this.FormView1.FindControl("FileExtLabel2"); Label DocVersIDLabel2 = (Label)this.FormView1.FindControl("DocVersIDTextbox"); //int New_or_Replace = this.FormView1.FindControl("RadioButtonList1"); //string path = ConfigurationManager.AppSettings["DOCUMENT_LOCATION"]; //string path_replace = path + @"ReplacedDocs\"; string path = Server.MapPath("~/webdocs/"); string path_replace = path + "/ReplacedDocs/"; bool fileOK; fileOK = false; // Before attempting to perform operations // on the file, verify that the FileUpload // control contains a file. if (FileUpload2.HasFile) { Label DocVersIDLabel_Edit = (Label)FormView1.FindControl("DocVersIDLabel_Edit"); String DocVersID = DocVersIDLabel_Edit.Text; String filePath = System.IO.Path.GetFullPath(FileUpload2.FileName); String fileExtension = System.IO.Path.GetExtension(FileUpload2.FileName).ToLower(); //String[] allowedExtensions = { ".docx", ".xlsx", ".pptx", ".ppt", ".doc", ".pdf", ".txt", ".xls", ".gif", ".png", ".jpeg", ".jpg", ".bmp", ".sps", ".sav", ".spo", ".rtf" }; for (int i = 0; i < allowedExtensions.Length; i++) { if (fileExtension == allowedExtensions[i]) { fileOK = true; } } if (fileOK) { try { ((Label)FormView1.FindControl("FileExtLabel2")).Text = fileExtension; ((Label)FormView1.FindControl("FileUploadLabel2")).Text = "DocVersID_" + DocVersID + fileExtension; //((Label)FormView1.Row.Cells[0].FindControl("FileUploadLabel2")).Text = FileUpload2.FileName; //copy the original to the "ReplacedDocs" folder string oldfilename = path + "DocVersID_" + DocVersID + ViewState["fileext"].ToString(); string newfilename = path_replace + "DocVersID_" + DocVersID + "__" + DateTime.Now.Year.ToString() + "_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "__" + DateTime.Now.Hour.ToString() + "hrs" + DateTime.Now.Minute.ToString() + "mins" + ViewState["fileext"].ToString(); //string oldfilename = @"\\autism-fs01\d$\WebDocs\DocVersID_" + DocVersID + ViewState["fileext"].ToString(); //string newfilename = @"\\autism-fs01\d$\WebDocs\ReplacedDocs\DocVersID_" + DocVersID + "__" + // DateTime.Now.Year.ToString() + "_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "__" + // DateTime.Now.Hour.ToString() + "hrs" + DateTime.Now.Minute.ToString() + "mins" + ViewState["fileext"].ToString(); File.Copy(oldfilename, newfilename); File.Delete(oldfilename); FileUpload2.PostedFile.SaveAs(path + "DocVersID_" + DocVersID + fileExtension); MessageBox2.Show("File copied."); //jmError.Text = oldfilename + " " + newfilename; } catch (Exception ex) { // ((Label)FormView1.Row.Cells[0].FindControl("FileUploadLabel1")).Text = "File could not be uploaded."; jmError.Text = "ERROR: File could not be uploaded. (" + ex.Message + ")"; } //HtmlControl frame1 = (HtmlControl)theFrameHolder.FindControl("frame1"); //frame1.Attributes["src"] = ""; //LoadDoc(); } else { // MessageBox2.Show("Cannot accept files of this type."); } } }
private void button2_Click(object sender, EventArgs e) { MessageBox2.Show("This is MessageBox2", "Caption Text", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, true, null); }
private void button1_Click(object sender, EventArgs e) { MessageBox2.Show("This is MessageBox2", true, null); }