Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How can I use the AsyncFileUpload control from ajaxtoolkit in vb.net?
Posted

I am just writing an example...you can alter it according to your requirement.

the script will be like this

XML
<script type = "text/javascript" >

function getFileAs()
{
document.getElementById ("<%=txtFileAs.ClientId%>").value = document.getElementById ("<%=txtEmployeeName.ClientId%>").value
}
</script>
<script type = "text/javascript">
        function uploadComplete(sender) {
            $get("<%=lblStatus.ClientID%>").innerHTML = "File Uploaded Successfully";
        }
        function uploadError(sender) {
            $get("<%=lblStatus.ClientID%>").innerHTML = "File upload failed.";
        }
</script>


The asp control

ASP.NET
<asp:AsyncFileUpload ID="AsyncFileUpload1"  OnClientUploadError="uploadError" OnClientUploadComplete="uploadComplete"
        runat="server"  UploaderStyle="Modern" CompleteBackColor="White"
        UploadingBackColor="#CCFFFF" ThrobberID="imgLoader" 
                OnUploadedComplete="AsyncFileUpload1_UploadedComplete" 
                FailedValidation="False" />
    <asp:Image ID="imgLoader" runat="server" ImageUrl="~/Images/indicator.gif" />
    <asp:Label ID="Throbber" runat="server" Style="display: none">
            <img src="~/Images/indicator.gif" align="absmiddle" alt="loading" />
        </asp:Label>
            <asp:Label ID="lblStatus" runat="server" 
                Style="font-family: Arial; font-size: small;"></asp:Label>



The VB Code

VB
Public Sub AsyncFileUpload1_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs)
        System.Threading.Thread.Sleep(5000)
        If AsyncFileUpload1.HasFile Then

            Session("link") = Path.GetFileName(e.FileName)
            Dim strPath As String = MapPath("~/Uploads/") + Path.GetFileName(e.FileName)
            AsyncFileUpload1.SaveAs(strPath)
        End If
    End Sub
 
Share this answer
 
v3
Comments
caspi.rulez 10-Aug-12 6:51am    
nice ans...thanx :)
 
Share this answer
 
v2

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