An uploaded file with RadAsyncUpload is missing after using a RadConfirm

4 posts, 0 answers
  1. Gioce90
    Gioce90 avatar
    16 posts
    Member since:
    Nov 2015

    Posted 24 Jan Link to this post

    I use a Telerik control in my page, the RadAsyncUpload. Is really simple and clear to use, but I want also this: if the file size to upload is greater than 20KB, the page must show a message (using a RadConfirm): "can take a while. Are you sure?"
    And here start the problems. When the file's size is <20KB is all okay, but in the other case.. I lost the file persistence! How can I fix it?
    I show you my code

     

     

    In the .aspx:

    ...
    <script language="javascript" type="text/javascript">
        function confirmCallbackFn(arg) {
            $get("<%=HiddenField_ConfirmResponse.ClientID %>").value = arg;
            $find("<%=RadAjaxManager1.ClientID >").ajaxRequest("confirmCallBack");
        }
    </script>
     
    ...
     
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
     
    <asp:HiddenField runat="server" ID="HiddenField_ConfirmResponse" />
     
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"  OnAjaxRequest="OnAjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadUploadTracciato" >
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="HiddenField_ConfirmResponse" />
                    <telerik:AjaxUpdatedControl ControlID="RadUploadTracciato" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
     
    <telerik:RadWindowManager runat="server" ID="RadWindowManager1" Width="700px" Modal="true"
        Height="500px" Behaviors="Maximize,Close,Move" VisibleStatusbar="true">
    </telerik:RadWindowManager>
     
    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1"></telerik:RadAjaxLoadingPanel>
     
    ...
     
    <telerik:RadAsyncUpload  ID="RadUploadTracciato" ForeColor="#103184" runat="server" PostbackTriggers="bValida" OnFileUploaded="RadAsyncUpload1_FileUploaded"
    InitialFileInputsCount="1" MaxFileInputsCount="1" OverwriteExistingFiles="true" ControlObjectsVisibility="None" AllowedFileExtensions=".xlsx,.txt" EnableFileInputSkinning="True" ReadOnlyFileInputs="True"  >      </telerik:RadAsyncUpload>
     
    <telerik:RadButton ID="bValida" Width="100" runat="server" Class="BtnAxa" Text="Carica" Style="margin-left: 75px !important;" ></telerik:RadButton>

     

    In my .cs:

     

    public void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
        {
        const int MaxTotalBytes = 20000;
     
        if (e.File.ContentLength < MaxTotalBytes)
        {
            UploadFile();
        }
        else
        {
     
            RadWindowManagerValidazione.RadConfirm("Il file è molto grande. Il caricamento potrebbe metterci qualche minuto",
                "confirmCallbackFn", 400, null, null, "Attenzione!");
        }
    }
     
     
    protected void OnAjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
    {
        if (e.Argument == "confirmCallBack" && HiddenField_ConfirmResponse.Value == "true")
        {
            UploadFile();
        }
    }
     
     
    protected void UploadFile()
    {
        if (RadUploadTracciato.UploadedFiles.Count > 0) // is alwais == 0 :(
        {...}
    }

     

     

     Someone can help me?

     

     

     

     

     

     

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 27 Jan Link to this post

    Hello Gioacchino,

    Please, try the approach demonstrated in the attached sample page. It shows how you can check the file size on the client and if it is larger than 20000 bytes the Confirm dialog will be displayed, the user's choice will be saved in the HiddenField, the server-side FileUploaded event will fire, in its handler (RadUploadTracciato_FileUploaded) you can get the value of the HiddenField and save the file if it is "true".

    Regards,
    Ivan Danchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Gioce90
    Gioce90 avatar
    16 posts
    Member since:
    Nov 2015

    Posted 28 Jan in reply to Ivan Danchev Link to this post

    doesn't work.

    args.get_fileInputField() doesn't have files property.

  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 28 Jan Link to this post

    Hello Gioacchino,

    Are you sure you are accessing args in the AsynUpload's OnClientFileSelected event handler as shown in the sample project I attached in my previous reply? Here's a short video, which shows that the property exists and can be accessed.

    Regards,
    Ivan Danchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top