This is a migrated thread and some comments may be shown as answers.

An uploaded file with RadAsyncUpload is missing after using a RadConfirm

3 Answers 202 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Gioce90
Top achievements
Rank 1
Gioce90 asked on 24 Jan 2016, 08:58 PM

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?

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 27 Jan 2016, 04:41 PM
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
0
Gioce90
Top achievements
Rank 1
answered on 28 Jan 2016, 10:45 AM

doesn't work.

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

0
Ivan Danchev
Telerik team
answered on 28 Jan 2016, 03:49 PM
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
Tags
AsyncUpload
Asked by
Gioce90
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Gioce90
Top achievements
Rank 1
Share this question
or