Hi,
i've this code aspx and vbnet 2010:
how can I start the progressbar simultaneously upload the file? calculate the actual file transfer?
i've this code aspx and vbnet 2010:
how can I start the progressbar simultaneously upload the file? calculate the actual file transfer?
<
form
id
=
"form1"
runat
=
"server"
style
=
"font-family: Verdana; font-size: small; background-image: url('Image/Upload.jpg'); background-repeat: no-repeat; width: 640px; height: 480px"
>
<
div
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
Runat
=
"server"
>
</
telerik:RadScriptManager
>
<
br
/>
<
table
style
=
"border: 0px; margin: 0px; padding: 0px; width: 100%"
>
<
tr
>
<
td
style
=
"border-style: none; border-color: inherit; border-width: 0px; margin: 0px; padding: 0px; text-align: center;"
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"border-style: none; border-color: inherit; border-width: 0px; margin: 0px; padding: 0px; text-align: center;"
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"border-style: none; border-color: inherit; border-width: 0px; margin: 0px; padding: 0px; text-align: center;"
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"border-style: none; border-color: inherit; border-width: 0px; margin: 0px; padding: 0px; text-align: center;"
>
<
telerik:RadUpload
ID
=
"RadUpload1"
Runat
=
"server"
AllowedFileExtensions
=
"jpg,jpeg,png,gif"
OverwriteExistingFiles
=
"True"
TargetFolder
=
"public/image_profile"
ControlObjectsVisibility
=
"None"
InputSize
=
"50"
Height
=
"22px"
style
=
"text-align: left"
Skin
=
"Sunset"
>
<
Localization
Select
=
"Cerca"
/>
</
telerik:RadUpload
>
<
asp:CustomValidator
ID
=
"CustomValidator1"
runat
=
"server"
ErrorMessage
=
"File errato"
ClientValidationFunction
=
"validateRadUpload"
OnServerValidate
=
"CustomValidator1_ServerValidate"
ForeColor
=
"Red"
></
asp:CustomValidator
>
<
div
style
=
"font-size:x-small"
>Il file deve avere le seguenti estensioni: .jpg, .jpeg, .png
</
div
>
<
div
>
</
div
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Avvia trasferimento"
Skin
=
"Sunset"
>
</
telerik:RadButton
>
<
script
type
=
"text/javascript"
>
function validateRadUpload(source, e) {
e.IsValid = false;
var upload = $find("<%= RadUpload1.ClientID %>");
var inputs = upload.getFileInputs();
for (var i = 0; i <
inputs.length
; i++) {
//check for empty string or invalid extension
if (inputs[i].value != "" && upload.isExtensionValid(inputs[i].value)) {
e.IsValid
=
true
;
break;
}
}
}
</script>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"border-style: none; border-color: inherit; border-width: 0px; margin: 0px; padding: 0px; text-align: center;"
>
<
div
>
</
div
>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text
=
"Nessun file caricato"
ForeColor
=
"Green"
></
asp:Label
>
<
asp:Repeater
ID
=
"Repeater1"
runat
=
"server"
Visible
=
"False"
>
<
HeaderTemplate
>
<
div
style
=
"color: green"
>
File caricato:</
div
>
</
HeaderTemplate
>
<
ItemTemplate
>
<%#DataBinder.Eval(Container.DataItem, "FileName")%>
<%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%>
<
br
/>
</
ItemTemplate
>
</
asp:Repeater
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"border-style: none; border-color: inherit; border-width: 0px; margin: 0px; padding: 0px; text-align: center;"
>
<
telerik:RadProgressManager
ID
=
"RadProgressManager1"
runat
=
"server"
/>
<
telerik:RadProgressArea
ID
=
"RadProgressArea1"
Runat
=
"server"
ProgressIndicators
=
"FilesCountBar, FilesCount, FilesCountPercent, SelectedFilesCount, CurrentFileName"
>
<
Localization
Uploaded
=
"Trasferito"
CurrentFileName
=
"Trasferimento file:"
EstimatedTime
=
"Tempo stimato:"
Total
=
"Totale "
TotalFiles
=
"Totale files: "
TransferSpeed
=
"Velocità : "
UploadedFiles
=
"File trasferiti:"
></
Localization
>
</
telerik:RadProgressArea
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"border-style: none; border-color: inherit; border-width: 0px; margin: 0px; padding: 0px; text-align: center;"
>
<
div
>
</
div
>
<
asp:ImageButton
ID
=
"Imgbtnesci"
runat
=
"server"
ImageUrl
=
"~/Image/esci1.png"
ValidationGroup
=
"esci"
/>
</
td
>
</
tr
>
</
table
>
</
div
>
</
form
>
Protected
Sub
RadButton1_Click(sender
As
Object
, e
As
System.EventArgs)
Handles
RadButton1.Click
If
RadUpload1.UploadedFiles.Count > 0
Then
UpdateProgressContext()
Repeater1.DataSource = RadUpload1.UploadedFiles
Repeater1.DataBind()
Label1.Visible =
False
Repeater1.Visible =
True
Else
Label1.Visible =
True
Repeater1.Visible =
False
End
If
End
Sub
Private
Sub
UpdateProgressContext()
Const
total
As
Integer
= 100
Dim
progress
As
RadProgressContext = RadProgressContext.Current
progress.Speed =
"N/A"
For
i
As
Integer
= 0
To
total - 1
progress.PrimaryTotal = 1
progress.PrimaryValue = 1
progress.PrimaryPercent = 100
progress.SecondaryTotal = total
progress.SecondaryValue = i
progress.SecondaryPercent = i
progress.CurrentOperationText =
"Step "
& i.ToString()
If
Not
Response.IsClientConnected
Then
Exit
For
End
If
progress.TimeEstimated = (total - i) * 100
System.Threading.Thread.Sleep(100)
Next
End
Sub
Protected
Sub
CustomValidator1_ServerValidate(source
As
Object
, e
As
System.Web.UI.WebControls.ServerValidateEventArgs)
Handles
CustomValidator1.ServerValidate
e.IsValid = (RadUpload1.InvalidFiles.Count = 0)
End
Sub