Ciao a tutti volevo chiedere come creare un messaggio di attesa durante l'upload di un file.
Ho usato questo nel file .aspx
Volevo mettere un messaggio nella label lblMessaggio del tipo "Caricamento in corso"codice:<form id="form1" runat="server"> <div> <asp:FileUpload ID="FileUpload1" runat="server" /> <asp:Button ID="Button1" runat="server" Text="Carica" /> <asp:Label ID="lblMessaggio" runat="server"></asp:Label> </div> </form>
Questo è quello che accade con la pressione del pulsante. Il fatto è che pensavo si potesse fare come con ASP classico e mettere appena dopo la pressione del pulsante una cosa del tipocodice:Partial Class Amministratore_pop_File Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim blnOk As Boolean If FileUpload1.HasFile Then Dim strCartella As String = Request.QueryString("dir") Dim strID As String = Request.QueryString("id") Dim strFrm As String = Request.QueryString("frm") Dim strCampo As String = Request.QueryString("campo") Dim strBottone As String = Request.QueryString("btn") Dim strNuovoNomeFile As String = Date.Now.ToString Dim strIcona As String Dim strInput As String = Request.QueryString("input") Dim strEstensione As String = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName) strNuovoNomeFile = Replace(strNuovoNomeFile, "\", "") strNuovoNomeFile = Replace(strNuovoNomeFile, "/", "") strNuovoNomeFile = Replace(strNuovoNomeFile, " ", "") strNuovoNomeFile = Replace(strNuovoNomeFile, ".", "") strNuovoNomeFile += strEstensione If strCartella = "" Then strCartella = "Files" Try If Request.QueryString("tipo") = "jpg" Then If FileUpload1.PostedFile.ContentType = "image/pjpeg" Then 'FileUpload1.SaveAs(Server.MapPath("/concorso/Immagini/" & strCartella) & "\" & FileUpload1.FileName) FileUpload1.SaveAs(Server.MapPath("/public/" & strCartella) & "\" & strNuovoNomeFile) lblMessaggio.Text = "File inserito con successo " & _ "Nome del file: " & FileUpload1.PostedFile.FileName & " " & _ "Dimensioni: " & FileUpload1.PostedFile.ContentLength & " " & _ "Tipo file: " & FileUpload1.PostedFile.ContentType blnOk = True Else lblMessaggio.Text += "Si possono caricare solo file .jpg" blnOk = False End If Else FileUpload1.SaveAs(Server.MapPath("/public/" & strCartella) & "\" & strNuovoNomeFile) lblMessaggio.Text = "File inserito con successo " & _ "Nome del file: " & FileUpload1.PostedFile.FileName & " " & _ "Dimensioni: " & FileUpload1.PostedFile.ContentLength & " " & _ "Tipo file: " & FileUpload1.PostedFile.ContentType Select Case strEstensione Case ".zip" strIcona = "Immagini/zip.gif" Case ".jpg" strIcona = "Immagini/jpg.gif" Case ".pdf" strIcona = "Immagini/pdf.gif" Case ".mdb" strIcona = "Immagini/mdb.gif" Case ".rar" strIcona = "Immagini/rar.gif" Case ".exe" strIcona = "Immagini/exe.gif" Case ".txt" strIcona = "Immagini/txt.gif" Case ".eml" strIcona = "Immagini/eml.gif" Case ".gif" strIcona = "Immagini/gif.gif" Case ".html", ".htm", ".asp", ".aspx" strIcona = "Immagini/htm.gif" Case ".mp3", ".wav", ".mid", ".mpe", ".mpeg", ".mpg" strIcona = "Immagini/mp3.gif" Case ".psd" strIcona = "Immagini/psd.gif" Case ".doc" strIcona = "Immagini/doc.gif" Case ".pdf" strIcona = "Immagini/pdf.gif" Case ".ppt" strIcona = "Immagini/ppt.gif" Case ".xls" strIcona = "Immagini/xls.gif" Case ".pps" strIcona = "Immagini/ppt.gif" Case Else strIcona = "Immagini/other.gif" End Select blnOk = True End If Catch ex As Exception lblMessaggio.Text += "ERRORE: " & ex.Message.ToString() blnOk = False End Try 'Se è andato a buon fine devo aggiornare la pagina padre If blnOk = True Then Dim myScript As String 'myScript = "window.opener." & strFrm & "." & strCampo & ".value='" & FileUpload1.FileName & "';" 'myScript = "window.opener." & strFrm & "." & strCampo & ".value='" & strNuovoNomeFile & "';" myScript = "window.opener.document.getElementById('" & strCampo & "').value='" & strNuovoNomeFile & "';" If strID <> "" And Request.QueryString("tipo") = "jpg" Then 'myScript += " window.opener.document." & strID & _ '".src='../zoom.aspx?imgfile=Immagini/" & strCartella & "/" & FileUpload1.FileName & _ '"&width=120&height=90';" myScript += " window.opener.document." & strID & _ ".src='../zoom.aspx?imgfile=public/" & strCartella & "/" & strNuovoNomeFile & _ "&width=120&height=90';" myScript += " window.opener.document." & strID & _ ".style.display='';" Else myScript += " window.opener.document." & strID & _ ".src='" & strIcona & "';" myScript += " window.opener.document." & strID & _ ".style.display='';" myScript += " window.opener.document.getElementById('" & strInput & _ "').style.display='';" myScript += " window.opener.document.getElementById('messaggioupload').innerHTML='File caricato con successo';" End If 'myScript += " window.opener." & strFrm & "." & strBottone & ".style.display='none';" myScript += " window.opener.document.getElementById('" & strBottone & "').style.display='none';" myScript += " window.close();" Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "myScript", myScript, True) Else lblMessaggio.Text += "Nessun file caricato" blnOk = False End If End If End Sub End Class
Ma non lo considera. Come si può far comparire un messaggio prima che l'operazione sia completata?codice:lblMessaggio.Text = "Caricamento in corso" Response.Flush()
Grazie mille.


Rispondi quotando
era ora
