Question

I want to upload a file using AjaxFileUpload control. This works fine.The problem is i am not able to display the success/failure message on Label of file uploaded.

.aspx code..

<form id="form1" runat="server">
    <div>
    <div></div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <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:Label>
                <asp:AjaxFileUpload ID="AjaxFileUpload1" 
                    runat="server" 
                    OnUploadComplete="AjaxFileUpload1_UploadComplete" 
                    OnClientUploadError="uploadError" 
                    OnClientUploadComplete="uploadComplete"
                    ThrobberID="myThrobber"
                    MaximumNumberOfFiles="1"
                    AllowedFileTypes="" 
                    class="name_text1" 
                    Width="200px" />
                <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
                <asp:Button ID="BtnClose" runat="server" Text="Close" 
                   onclick="BtnClose_Click" OnClientClick="Closepopup()"/>

                <asp:Label ID="Label2" runat="server" Text=""></asp:Label>

                <br />
            </ContentTemplate>
        </asp:UpdatePanel>

    </div>
    </form>

i want to display text on Label2 that file uploaded or not. my .cs code:

protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
 string message = "Storege Space is Exceeding its Limit";
                    Label2.Text = message;
}

How to display message on Label ? Any Suggesstion? Help appreciated

No correct solution

OTHER TIPS

It might be problem due to update panel,

You have put the AjaxFileUpload inside the update panel, so update panel controls not update all controls when ever your label fill with text in AjaxFileUpload1_UploadComplete event.

So please try after remove update panel or set the property UpdateMode="Conditional" of update panel.

Hope this will helpful to solve out your problem.

The latest version of the ajax file upload comes with an update progress.So if you use it, you don't have to put a label to display the failure/success text. For more information and demo see this page : http://stephenwalther.com/archive/2012/05/01/ajax-control-toolkit-may-2012-release.aspx

function ReBindMaterialsGrid() {
    if (rebindTimer == null) {
        SetRebindTimeout();
    } else {
        clearTimeout(rebindTimer);
        SetRebindTimeout();
    }
}
function SetRebindTimeout() {
    rebindTimer = setTimeout(
        'var btn = document.getElementById("MainContent_AdminTabs_TabContainerMain_TabPanelMaterials_Materials_btnReBindGrid");' +
        'btn.click();', 8888);
}

                                                       <asp:UpdatePanel ID="UpdatePanelUpload" runat="server">
                                                        <ContentTemplate>
                                                            <asp:Label runat="server" ID="lblThrobber" Style="display: none;">
                                                    <img src="../../Images/loading.gif" alt="Loading..." />
                                                            </asp:Label>
                                                            <asp:HiddenField ID="hdStitchAssetPathUpload" Value='<%# Eval("StitchAssetPath") %>'
                                                                runat="server" />
                                                            <asp:AjaxFileUpload ID="AjaxFileUploadPlank" ThrobberID="lblThrobber" runat="server"
                                                                OnUploadComplete="AjaxFileUploadPlank_UploadComplete" OnClientUploadComplete="ReBindMaterialsGrid" />
                                                        </ContentTemplate>
                                                    </asp:UpdatePanel>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top