📄 defaultvb.aspx.vb
字号:
Imports System.IO
Namespace Telerik.UploadExamplesVBNet.ServerSideAPI
Public Class DefaultVB
Inherits Telerik.QuickStart.XhtmlPage
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents lblInvalidMessage As System.Web.UI.WebControls.Label
Protected WithEvents upload1 As Telerik.WebControls.RadUpload
Protected WithEvents progressArea1 As Telerik.WebControls.RadUploadProgressArea
Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub upload1_ValidatingFile(ByVal sender As Object, ByVal e As WebControls.ValidateFileEventArgs) Handles upload1.ValidatingFile
If Path.GetExtension(e.UploadedFile.FileName).ToLower = ".zip" Then
Dim maxZipFileSize As Integer = 10000000 '~10MB
If e.UploadedFile.ContentLength > maxZipFileSize Then
e.IsValid = False
End If
e.SkipInternalValidation = True
End If
' For example you can Get these from your web.config file
Dim commaSeparatedMimeTypes As String = "application/octet-stream,application/msword,video/mpeg"
Dim allowedMimeTypes As String() = New String(2) {"asdasda", "asdasda", "asdasd"}
upload1.AllowedMimeTypes = allowedMimeTypes
upload1.ControlObjectsVisibility = WebControls.ControlObjectsVisibility.AddButton Or _
WebControls.ControlObjectsVisibility.RemoveButtons
Dim file As Telerik.WebControls.RadUploadUtils.UploadedFile
End Sub
Private Sub RadUpload1_FileExists(ByVal sender As Object, ByVal e As Telerik.WebControls.UploadedFileEventArgs) Handles upload1.FileExists
Dim FileName As String = Path.GetFileNameWithoutExtension(e.UploadedFile.FileName)
Dim FileExt As String = Path.GetExtension(e.UploadedFile.FileName)
e.UploadedFile.SaveAs(Path.Combine(upload1.TargetFolder, FileName + "1" + FileExt))
End Sub
End Class
End Namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -