Introduction
Ajax (Asynchronous JavaScript and XML) is a new web development technique for interactive websites. With the help of AJAX we can develop web applications and retrieve a small amount of data from the web server. AJAX consists of a different type of technology.
- JavaScript
- XML
- Asynchronous Call to the server
AsyncFileUpload Control
AsyncFileUpload is a new ASP.NET AJAX Control that allows you to asynchronously upload files to server. You don't need a separate upload button for this control. Add the AsyncFileUpload control and a label to the web form for the uploading and displaying of messages respectively. The file uploading results can be checked both in the server and client sides. You can save the uploaded file by calling the SaveAs() method in a handler for the server UploadedComplete event.
Property
- OnClientUploadComplete
- OnClientUploadError
- UploaderStyle
- CompleteBackColor
- ThrobberID
Step 1 : Open Visual Studio 2010.
- Go to File->New->WebSite
- Select ASP.NET Empty WebSite

Step 2 : Go to Solution Explorer and right-click.
- Select Add->New Item
- Select WebForm
- Default.aspx page open

Step 3 : Go to Default.aspx page and click on the [Design] option and drag control from Toolbox.
- Drag UpdatePanel, ScriptManager, Label
Define Script Function
Step 4 : Go to Default.aspx page[Source]option and define the <script> function for the AsyncFileUpload and define upload complete function.
Code :
<script type = "text/javascript">
function uploadComplete(sender) {
$get("<%=lblMesg.ClientID%>").innerHTML = "File Uploaded Successfully";
}
function uploadError(sender) {
$get("<%=lblMesg.ClientID%>").innerHTML = "File upload failed.";
}
</script>
Step 5 : Go to Default.aspx page[Design] option drag image control from Toolbox and define URL property.
<asp:Image ID="Image1" runat="server" ImageUrl="~/images......jpg" />
Step 6 : Go to Default.aspx[source]option and drag an AsyncFileUpload Control from the Toolbox and define the OnClientUploadComplete and OnClientUploadError event handlers.

Code :
<asp:AsyncFileUpload ID="AsyncFileUpload1" OnClientUploadComplete="uploadComplete" OnClientUploadError="uploadError" runat="server" Width="400px" UploaderStyle="Modern" CompleteBackColor = "White" UploadingBackColor="#CCFFFF" ThrobberID="Image1" OnUploadedComplete = "FileUploadComplete" BackColor="#54AB82" />
<ContentTemplate>
Step 7 : Go to Default.aspx page[Design] option and right-click on UpdatePanel.
- Property-> ChildrenAsTrigger "True";

Code :
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:AsyncFileUpload ID="AsyncFileUpload1" OnClientUploadComplete="uploadComplete" OnClientUploadError="uploadError" runat="server" Width="400px" UploaderStyle="Modern" CompleteBackColor = "White" UploadingBackColor="#CCFFFF" ThrobberID="Image1"
OnUploadedComplete = "FileUploadComplete" BackColor="#54AB82" />
<asp:Image ID="Image1" runat="server" ImageUrl="~/images......jpg" />
<br />
<asp:Label ID="lblMesg" runat="server" BackColor="#CECACD"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
Step 8 : Go to Default.aspx.cs file option and write a code.


YohannPosted Sep 13, 2012, 10:20 AM
This worked for me as well as resolving a couple annoying issues I was facing. Worth the time spent to test it out
Chandra ShekharPosted Jul 3, 2012, 2:05 AM
how to display image from folder in asp.net3.5