Dunque, premetto che anche se in asp classic sviluppo in vbscript in asp.net utilizzo C# quindi vado un po a tentoni.
Nell'utilizzo della tua classe vedo che tu istanziavi un oggetto di tipo
protected withEvents CmdUpload as button
mentre nell'aspx utilizzavi un
<input type="submit" id="CmdUpload" value="up" runat="server" />
che invece è di tipo htmlInputbutton, allo stesso modo l'evento scatenato dall'oggetto htmlInput è ServerClick non Click
quindi questo è il file upload.vb
codice:
Imports System.web.UI
Imports System.web.UI.WebControls
Imports System.web.UI.HtmlControls
Imports System.IO
Public Class uploadFile
inherits page
protected withEvents CmdUpload as htmlInputbutton
protected lblInfo as Label
protected fileInput as htmlInputFile
Private sub page_load(sender as object, e as eventArgs)
fileInput.accept = "image/*"
end sub
Private Sub CmdUpload_ServerClick (sender as object, e as eventArgs) handles CmdUpload.ServerClick
if fileInput.value = "" then 'con il tuo controllo non era mai nothing cosi controlla il valore inserito
lblInfo.text="Specificare file"
else
try
dim serverfilename as string
serverFilename=path.getFileName (fileInput.postedFile.FIlename)
fileinput.postedFile.saveAs("F:\root\asp.net\"&serverfilename)
lblInfo.text="File " & serverfilename & " caricato correttamente"
catch err as exception
lblInfo.text=err.message
end try
end if
end sub
end Class
cosi lo includi nella pagina aspx
codice:
<%@ Page Language="VB" Src="upload.vb" inherits="uploadFile" %>
<html>
<body>
<form id="form" runat="server" enctype="multipart/form-data">
<input type="file" id="fileInput" runat="server" />
<input type="submit" id="CmdUpload" value="up" runat="server"/>
<asp:label id="lblInfo" runat="server" />
</form>
</body>
</html>