I'm using the ASP.NET FileUpload control.
To upload a file, a user must:
- Browse to select a file from his/her device,
- Click the upload button to upload the file to the server.
Is it possible to skip step 2 (the Upload button) and call the 'uploadFile_Click' function on the server through a jquery (postback) once a file is selected? I'm trying the following method but I need some help to finalize it.
ASPX PAGE
<asp:FileUpload runat="server" ID="UploadImages" />
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="UploadImages" ClientValidationFunction="ValidateUpload" />
CODE BEHIND
protected void uploadFile_Click(object sender, EventArgs e)
{
// Upload code
}
JQUERY
function ValidateUpload() {
var FileUpload_function = document.getElementById('UploadImages');
if (FileUpload_function.value == '') {
return false;
}
else {
** Here I want to trigger a postback to call the uploadFile_Click. Is that possible? **
}
return true;
}