Becky Bloomwood

Becky Bloomwood

  • NA
  • 119
  • 285.8k

Display a msg box to prompt user if they want to overwrite exist filePosted by becky bloomwood in Visual Studio .NET

Feb 13 2011 11:51 AM
Hi, I have a grid view that allows user to upload MS excel file and PDF file into the database and download it. After they upload it, they are able to overwrite the exisiting file by clicking on the edit hyerplink and proceed on to upload a new document.How do we code out the code such that if user clicks on the edit btn and browser for a new file and click sumbit, there will be a msg box that prompt user if they want to overwrite the existing file, user can select either OK or cancel. if user selects Ok, they are able to overwrite the file successfully.

Also how do I code out such that if user upload a file that is of not accpetable format, it will prevent them from uplaoding the document. Thanks.
This is the business logic for it:

 

protected void gvTemplate_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddNew"))
{
TextBox txtTemplateID = (TextBox)gvTemplate.FooterRow.FindControl("txtTemplateID");
TextBox txtTemplateName = (TextBox)gvTemplate.FooterRow.FindControl("txtTemplateName");
TextBox txtFileName = (TextBox)gvTemplate.FooterRow.FindControl("txtFileName");
FileUpload txtFilePath = (FileUpload)gvTemplate.FooterRow.FindControl("txtFilePath");
 


vrmdb.Insert_TemplateRecords(txtTemplateID.Text, txtTemplateName.Text, txtFileName.Text, txtFilePath.FileName);
txtFilePath.SaveAs(Server.MapPath("~/Upload/") + txtFilePath.FileName);
BindGrid(true);
Response.Redirect("ContractTemplate.aspx");
}
Thanks!

Answers (1)