Having trouble with AsyncFileUpload not working inside Listview Insert, Edit Itemtemplate and EmptyData Template.
The following are my Client Side Functions:
function AttachmentUploadSuccessful() {
debugger;
var textError = $(".AttachmentError").text();
if (textError.length > 0) {
var text = $(".AttachmentError");
text.innerText = text.textContent = textError;
sender._onError(textError); // it will raise the OnClientUploadError event
return;
} else {
//alert(" File attachment is uploaded successfully.");
//CODE TO REMOVE FILE AND BACKGROUND COLOR OF FILE UPLOADER
$('.ModelBackgroundforCreateItem').hide();
$('.PopupPanel').hide();
var UploadControls = $('#<%= FileUpload.ClientID %> :input');
UploadControls.each(function () {
//$(this).val("");
$(this).css('background-color', '#fff');
});
//Updating Update panel by clicking button
$(".RefreshList").click();
}
}
function AttachmentUploadFailed() {
alert("An error occured while uploading File Attachment. ");
}
Markup in .aspx file
<asp:ListView ID="ListView2" runat="server">
<EmptyDataTemplate>
<table class="fileUpload" runat="server" id="FileUploadID">
<tr>
<td>
<div style="width: 350px; overflow-x: hidden;">
<asp:AsyncFileUpload runat="server" ID="FileUpload" ThrobberID="Throbber" OnClientUploadError="AttachmentUploadFailed"
OnClientUploadComplete="AttachmentUploadSuccessful" UploaderStyle="Traditional" UploadingBackColor="" Style="display: inline-block; margin-top: 5px;"
OnUploadedComplete="FileUpload_UploadedComplete">
</asp:AsyncFileUpload>
</div>
</td>
<td style="width: 30px">
<asp:Image ID="Throbber" ImageUrl="~/Image/AttachmentLoading.gif" Style="display: None; width: 20px;" runat="server" />
<br />
</td>
</tr>
</table>
</EmptyDataTemplate>
</asp:ListView>
Encountering an issue where the Client side event OnClientUploadError
is getting called but causing errors when trying to upload a file inside a Listview.
Tried on a simple page and within Update panel where it worked fine, but inside Listview it's throwing client error.
Checked similar posts online but couldn't find a solution, need assistance.
How to find Ajaxfileupload control inside Listview When in Editmode
AsyncFileUpload within EditItemTemplate of ListView