I agree with
@Zafar Sultan.
But I am sharing another way to do it in client side.
If you can go through
AjaxFileUpload Demonstration[
^] and maximize the Link
AjaxFileUpload Events, Properties and Methods, then you will see all the details like below.
Events
UploadedComplete - Raised on the server when a file is uploaded successfully. In this event an instance of AjaxFileUploadEventArgs is passed in the argument that contains file name, size and content type.
Properties
ThrobberID - The ID of a control that is shown while the file is uploading. The throbber image is displayed for browsers that do not support the HTML5 File API.
ContextKeys - A dictionary that can be used to pass information to the server when a file is uploaded.
MaximumNumberOfFiles - This property enables you to limit the number of files that a user can add to the upload queue.
AllowedFileTypes - This property enables you to restrict the types of files that can be uploaded. You can assign a comma delimited list of file extensions to this property.
IsInFileUploadPostBack - This property has the value true when a page is created in response to an AjaxFileUpload asynchronous postback.
OnClientUploadComplete - The name of a JavaScript function executed in the client-side after a file is uploaded successfully.
OnClientUploadError - The name of a JavaScript function executed in the client-side if the file upload failed.
Methods
SaveAs(string filename) - Saves the contents of an uploaded file to the file system. Your application must have the required Write permissions.
So, you can use the properties
1.
OnClientUploadComplete for upload success and
2.
OnClientUploadError for upload error.
Codes
Mark up will be like below...
<asp:AjaxFileUpload ID="AjaxFileUpload1"
runat="server"
OnUploadComplete="AjaxFileUpload1_UploadComplete"
OnClientUploadError="uploadError"
OnClientUploadComplete="uploadComplete"
ThrobberID="myThrobber"
MaximumNumberOfFiles="1"
AllowedFileTypes=""
class="name_text1"
Width="200px" />
The JavaScript will be like below...
<script type="text/javascript">
function uploadComplete(sender) {
$get("<%=Label2.ClientID%>").innerHTML = "File Uploaded Successfully";
}
function uploadError(sender) {
$get("<%=Label2.ClientID%>").innerHTML = "File upload failed.";
}
</script>