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?