Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have code:

ASP.NET
<form id="form1"  runat="server">
    <div>
    <div></div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <contenttemplate>
                <asp:Label runat="server" ID="myThrobber" Style="display: none;"><img align="absmiddle" alt="" src="images/uploading.gif"/>
                <asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" OnUploadComplete="AjaxFileUpload1_UploadComplete" 
                    OnClientUploadError="" ThrobberID="myThrobber" MaximumNumberOfFiles="1" AllowedFileTypes="" class="name_text1" Width="200px" />
                <asp:Label ID="Label1" runat="server" Text="">
                <asp:Button ID="BtnClose" runat="server" Text="Close" 
                   onclick="BtnClose_Click" OnClientClick="Closepopup()"/>
                
                <asp:Label ID="Label2" runat="server" Text="">
                
                <br />
            </contenttemplate>
        
         
    </div>
    </form>

.....................
i want to to display file upload or not on <Label2> please help me...
Posted
Updated 1-Jan-13 20:46pm
v2

You are already using "AjaxFileUpload1_UploadComplete" event. Why not to use it? Set the label's text in this event.
 
Share this answer
 
Comments
oliver36 4-Sep-14 0:20am    
setting label text in "AjaxFileUpload1_UploadComplete" will not make changes of text to label.
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...
XML
<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...
JavaScript
<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>
 
Share this answer
 
v3
 
Share this answer
 

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