INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Javascript needs to run fileupload if "OK" is licked for overwrite

Javascript needs to run fileupload if "OK" is licked for overwrite

Javascript needs to run fileupload if "OK" is licked for overwrite

(OP)
I have a form where a user uploads an excel file, renames the file then checks to see if the file exist. If it doesn't exist it saves fine. I get the message to overwrite if it exist, but when I click on the OK button nothing happens. How do I make this work? Thanks, I could really use your help. Here is my code:

//JavaScript Code
<script type="text/javascript" >
function Confirm()
{
window.onload = function () {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("File already exist. Do you want to overwrite?")) {
confirm_value.value = "Yes";
}
else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
document.getElementById("<%=btnSave.ClientID%>").click();
}
}
</script>

//VB.net try block from code
Try
If ext.Trim().ToLower() = "xls" Or ext.Trim().ToLower() = "xlsx" Then
saveInfo = "Original File Name: " & fileName & "<br/>"
saveInfo += "File Size: " & fuProductCapsuleEXCEL.PostedFile.ContentLength / 1000 & " Kilobytes <br/>"
saveInfo += "Content Type: " & fuProductCapsuleEXCEL.PostedFile.ContentType & "<br/>"
newFileName = salesYear + "-" + supCID + "." + ext
saveInfo += "New File Name: " + newFileName.ToString()

'check if file already exist
exist = CheckForDup(newFileName)

'if file doesent exist, add it to folder

If exist = False Then
fuProductCapsuleEXCEL.SaveAs(Application("IMARK_RootPath") & "/UPLOADED_FILE/G2G_SKUs/" + newFileName)
lblSaveInfo.Text = saveInfo.ToString()
End If

'file with newfilename already in folder. Check for overwrite
If exist = True Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "confirm", "Confirm()", True)

End If

End If

Catch ex As Exception
Throw ex

End Try

RE: Javascript needs to run fileupload if "OK" is licked for overwrite

that is vb.net. not javascript.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close