Click here to Skip to main content
15,891,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am trying to select an AsyncFileUpload id in order to save it into a database using JQuery, so I am trying to select its Id to see what is wrong but it is alerting with an empty value. Please I just need to know I am making a mistake somewhere. My code are down.

Thanks

What I have tried:

Here the html portion:

<asp:AsyncFileUpload OnClientUploadError="uploadFileError"
runat="server" ID="AsyncFileUpload2" Width="190px" CssClass="asyncupload" UploadingBackColor="#CCFFFF"
OnClientUploadStarted="OnUploadFileStart" OnUploadedComplete="AsyncFileUpload2_UploadedComplete" />


and this my Jquery selector:

var pdfname = $('#<%=txtBookTitle.ClientID%>').val();
                var pdfname1 = $('#<%=txtBookDescription.ClientID%>').val();
                var pdfname2 = $('#<%=AsyncFileUpload2.ClientID%>').val();
                alert(pdfname);
                alert(pdfname1);
                alert(pdfname2);
Posted
Comments
F-ES Sitecore 11-Apr-19 13:13pm    
Server-side controls (asp:AsyncFileUpload) only generate html which is sent to the client, and your jquery code runs on the html generated by the server control. When you use $('#<%=AsyncFileUpload2.ClientID%>') there is no way of knowing exactly what html element you are accessing as what html is generated depends on the server control. You'll need to look at the html of your page via view->source and try and work out what element contains the data you are looking for and how to access it.

Looking at the on-line example the async file upload generates a span and inside that span is a "hidden" input element and that is the element you want to access to get the filename.
El Dev 12-Apr-19 5:10am    
Hello F-ES Sitecore,
I am not getting you well, in few words how should I access the value cause I can see the file uploaded but am not able to select that value that has a .pdf extension...
Please help me by showing a JQuery selector as I am selecting other element and showing values like this line of code:
var pdfname = $('#<%=AsyncFileUpload2.ClientID%>').val();
alert(pdfname);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900